Inspiration

We wanted to turn backtesting, something that's usually slow, lonely, and static, into a live, head-to-head experience. The idea came from the passion for trading of one of our team members and some new tools that are coming up but unfortunately require a subscription-based engagement.

What it does

PaperDuel is an open-source competitive backtesting platform where two players trade simultaneously on historical market data, more specifically ES index futures contracts from 22:00:00 October 12th 2025 to October 17th 2025 20:59:00 for a total of one week worth of data or 6900 1 minute candlesticks (provided by Databento for free 🙂 ). We fast-forwarded the first 30 minutes of data to avoid uncertainty and to have structure on the left side of an entry (either way, most traders don't trade at market open on Sundays), so the earliest a user can enter a trade is at 22:30:00 10/12/2025. Each player can enter long or short, with as many contracts as desired (we never tried for an edge case because the usual amount of contracts per trade is 1-10 for most traders), with take profit and stop loss for each trade. Both users can enter at their own convenience based on technical analysis; their trades don't "overlap" or have to relate to each other. The chart replays minute-by-minute, with both users aiming to end with the highest equity. PaperDuel is like a backtesting platform, but you can "play" against a friend, making it more fun. Even for non-traders, it can be fun since, without proper technical analysis and risk management, trading is random.

How we built it

We started by designing the backend logic around a BattleService class in Python. It handles everything that happens behind the scenes — from loading market data to processing trades, calculating profit and loss, enforcing drawdown limits, and synchronizing turns between two players. Each “battle” runs as its own session using FastAPI, where both players connect through API endpoints like /battle/start, /battle/advance, and /battle/trade.

We used pandas to read and manage OHLCV (open, high, low, close, volume) data for assets like the S&P 500 (ES) and NASDAQ (NQ). The backend simulates fills, slippage, stop-loss and take-profit logic in real time, and returns updated battle states that the frontend can visualize.

On the frontend, we built a real-time chart interface using HTML, CSS, and Lightweight Charts, the same charting library used by TradingView. It replays historical market data as live candles while users trade using “BUY,” “SELL,” and “CLOSE” buttons. The UI updates dynamically after every bar, showing live equity, open positions, and execution logs.

Both layers communicate through simple fetch calls to the backend, and while the system supports unique battle IDs for multiplayer battles, the current version runs both users on the same device for easier testing and demoing during the hackathon.

Challenges we ran into

Getting the frontend and backend to “talk” properly took time. The candle data sometimes refused to render, and syncing trade logic between two users without breaking the chart replay was tricky. We also had to simplify a lot of the trading math to make it both fast and fair for a live match.

Accomplishments that we're proud of

We turned a technical backtesting engine into a fully interactive, competitive experience, complete with real-time candles, equity tracking, and user turns. Seeing the first duel actually run smoothly felt amazing.

What we learned

We learned a ton about bridging frontend frameworks with Python backends, handling real-time state updates, and how small design details (like pause/play logic or PnL displays) make the whole experience feel alive. Also we learned a lot about trading concepts!

What's next for PaperDuel

Next, we want to take PaperDuel beyond local testing and make it a fully interactive online experience. The goal is to enable players to connect from different devices using shared battle IDs and compete in real time. We also plan to introduce more time frames (like 5-minute, hourly, and daily data) and customizable time display formats to improve user comfort and realism. We also would like to add more data for backtesting, since one week is very limited. Also we need to implement the NQ index chart, which is already working conceptually but the chart is not complete yet, and with this one, more indexes in the future. On top of that, we want to add a leaderboard, player stats, and persistent user profiles so that PaperDuel feels more like a competitive trading arena than just a simulation tool.

Built With

Share this project:

Updates