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 second, minute, 5-minute, or 15-minute bars for instruments like NQ, ES, MNQ, MES, GC, and EURUSD — the finest bar depends on how each instrument is stored (EURUSD starts at 1m, GC at 10s).
- 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 50x 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.
- Gateway-schema API — The Python code talks to the Simulator API, which implements a common futures-gateway REST schema; bots written against that schema run on TestMax with a base-URL change.
How it works
The Playground follows a straightforward workflow:
- Configure — Pick an instrument, date range, timeframe, and strategy template (or write custom code).
- Run — Click “Run Backtest.” The server executes your Python script, stepping through historical bars one at a time.
- 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.
- 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 functions —
api(),place_order(),get_positions(),close_all_positions(),get_account() - Bar iteration —
get_next_bar()returns the next OHLCV bar from the replay - Speed control —
read_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.
| Template | Strategy Type | What It Does |
|---|---|---|
| SMA Crossover | Trend following | Buys when a fast moving average crosses above a slow moving average, sells on the opposite cross |
| RSI Scalper | Mean reversion | Buys when RSI drops below the oversold threshold, sells when it rises above overbought |
| Channel Breakout | Momentum | Buys on a price breakout above the recent highest high, sells on a breakdown below the lowest low |
| Custom | Your logic | Blank 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.
- Output — Real-time log output from your strategy (
- Account bar — Shows current balance, equity, unrealized P&L, and trade count.
Supported instruments
NQ, ES, MNQ, MES, and GC futures currently require Pro. Check the instrument picker or catalog for current availability. Oil replay uses LIGHTCMDUSD (WTI CFD); CL futures are not currently available.
The Algo Playground supports all instruments available in TestMax’s historical data library:
| Symbol | Instrument | Exchange | Tick Size |
|---|---|---|---|
| NQ | Nasdaq 100 E-mini | CME | 0.25 |
| ES | S&P 500 E-mini | CME | 0.25 |
| GC | Gold Futures | COMEX | 0.10 |
| EURUSD | Euro/US Dollar | Forex | 0.00001 |
Each instrument has different price characteristics, volatility profiles, and tick values. A strategy that works well on NQ may behave differently on GC due to differences in how these markets move. Always test your strategy on the specific instrument you plan to trade.
Available timeframes
| Timeframe | Resolution | Typical Use Case |
|---|---|---|
| 1s | 1-second bars | Ultra-high resolution scalping; only offered on instruments stored at 1-second resolution |
| 5s | 5-second bars | Short-term scalping |
| 1m | 1-minute bars | Most common for intraday strategies |
| 5m | 5-minute bars | Intraday swing trading |
| 15m | 15-minute bars | Longer-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.
Gateway compatibility
The Simulator API implements a common futures-gateway REST schema, so a Playground strategy can be pointed at any gateway that speaks the same schema by changing its base URL.
See Gateway Compatibility for what is shared and what is TestMax-only.