Skip to content
Back to App

Algo Playground

The Algo Playground is TestMax’s Python-based algorithm backtesting environment. Write trading strategies in Python, run them against real historical market data, and watch the results unfold in real time on an interactive chart.

Instead of manually replaying bars and clicking to place trades, you define your logic in code and let the Playground execute it bar-by-bar — placing orders, tracking positions, and calculating P&L automatically.

What you can do

  • Backtest strategies on historical data — Run your Python code against 1-second, 1-minute, 5-minute, or 15-minute bars for instruments like NQ, ES, GC, CL, and EURUSD.
  • Start from templates or write from scratch — Choose a pre-built strategy (SMA Crossover, RSI Scalper, Channel Breakout) or write completely custom logic.
  • Watch execution in real time — The chart updates live as your strategy processes each bar. Trade markers, candlesticks, and an equity curve render as the backtest runs.
  • Control playback speed — Adjust execution speed from 1x to 100x while the backtest is running. Slow down to study individual trades or speed up to see the full picture.
  • Save and compare strategies — Save your strategies with custom names, reload them later, and compare results across different runs and parameter sets.
  • Use the real TopStep API — The Python code uses the same API endpoints as the live TopStep ProjectX Gateway. When you are ready to trade live, the transition requires minimal code changes.

How it works

The Playground follows a straightforward workflow:

  1. Configure — Pick an instrument, date range, timeframe, and strategy template (or write custom code).
  2. Run — Click “Run Backtest.” The server executes your Python script, stepping through historical bars one at a time.
  3. Watch — A WebSocket connection streams results back to your browser. The chart renders candles, trade markers (green triangles for buys, red for sells), and the equity curve updates live.
  4. Analyze — When the backtest completes, review final P&L, win rate, total trades, and the full output log. Switch to the Trades tab for a detailed breakdown.

The Python environment

Each strategy runs as a standalone Python script on the server. TestMax provides a set of helper functions that handle API communication, order placement, position management, and bar iteration. You do not need to install any packages — the scripts use only Python standard library modules (os, sys, json, time, urllib).

Your strategy code has access to:

  • API functionsapi(), place_order(), get_positions(), close_all_positions(), get_account()
  • Bar iterationget_next_bar() returns the next OHLCV bar from the replay
  • Speed controlread_speed() reads the current playback speed from the UI
  • Environment variables — Instrument, date range, timeframe, account ID, contract ID, and custom parameters are all passed via environment variables

See the Python API Reference for complete documentation of every available function.

Strategy templates

Templates give you a working strategy out of the box. Each template includes configurable parameters so you can experiment without writing any code.

TemplateStrategy TypeWhat It Does
SMA CrossoverTrend followingBuys when a fast moving average crosses above a slow moving average, sells on the opposite cross
RSI ScalperMean reversionBuys when RSI drops below the oversold threshold, sells when it rises above overbought
Channel BreakoutMomentumBuys on a price breakout above the recent highest high, sells on a breakdown below the lowest low
CustomYour logicBlank template with all helper functions ready — write whatever you want

See Strategy Templates for detailed documentation on each one.

Interface layout

The Playground page is divided into several sections:

  • Left sidebar — Configuration panel with instrument, dates, timeframe, template selection, parameters, speed control, and the Run/Stop button.
  • Main chart — Candlestick chart with trade markers. Updates in real time during execution.
  • Equity curve — Line chart below the main chart showing your account balance over time.
  • Bottom panel — Tabbed area with three views:
    • Output — Real-time log output from your strategy ([INFO], [TRADE], [ERROR], [DONE] messages).
    • Code — Read-only view of the full Python script being executed (including the auto-generated header and setup code).
    • Trades — Table of all trades executed during the run, with entry/exit prices and P&L.
  • Account bar — Shows current balance, equity, unrealized P&L, and trade count.

Supported instruments

The Algo Playground supports all instruments available in TestMax’s historical data library:

SymbolInstrumentExchangeTick Size
NQNasdaq 100 E-miniCME0.25
ESS&P 500 E-miniCME0.25
GCGold FuturesCOMEX0.10
CLCrude Oil FuturesNYMEX0.01
EURUSDEuro/US DollarForex0.00001

Each instrument has different price characteristics, volatility profiles, and tick values. A strategy that works well on NQ may behave differently on CL due to differences in how these markets move. Always test your strategy on the specific instrument you plan to trade.

Available timeframes

TimeframeResolutionTypical Use Case
1s1-second barsUltra-high resolution scalping, tick analysis
5s5-second barsShort-term scalping
1m1-minute barsMost common for intraday strategies
5m5-minute barsIntraday swing trading
15m15-minute barsLonger-term intraday or multi-day analysis

Shorter timeframes produce more bars and take longer to process but provide finer detail. Longer timeframes run faster and are better for strategies that hold positions for extended periods.

TopStep compatibility

The Algo Playground uses the exact same API as the real TopStep ProjectX Gateway. This means the Python strategies you develop and test in TestMax can be adapted for live trading with minimal changes — primarily swapping the API URL and replacing get_next_bar() with a real-time data feed.

See TopStep Compatibility for a detailed migration guide.

Next steps