Gateway Compatibility
The Simulator API uses a common futures-gateway REST schema, so bots written against that schema run on TestMax with a base-URL change. A Playground strategy can be pointed at any gateway that speaks the same schema by changing TESTMAX_API_URL.
What the schema shares
TestMax implements the same endpoint names, request bodies and response shapes as the gateway schema:
| Endpoint | Behavior |
|---|---|
Account/search | Returns account info |
Order/place | Places a trading order (fills against historical data in TestMax) |
Position/searchOpen | Returns open positions |
Trade/search | Returns past trades |
When your strategy calls place_order(ACCOUNT_ID, CONTRACT_ID, 0, 1), the same JSON payload is sent regardless of which gateway is behind API_URL.
- All API endpoint paths —
Order/place,Account/search,Position/searchOpen, etc. - Request body format — Same JSON structure for all parameters
- Response body format — Same fields in all responses
- Authentication — Bearer token in the Authorization header
- Order types — Market (2), Limit (1), Stop (4) all work identically
- Side values — Buy (0) and Sell (1) are the same
- Contract IDs — Same format (e.g.,
CON.F.US.ENQ.H25)
What is TestMax-only
These parts exist only in the simulator, because they are what turns a trading API into a backtesting engine:
- Replay Control —
Replay/start,Replay/step,Replay/end,Replay/jumpTo,Replay/playandReplay/pause. See Replay Control. - Simulated withdrawals — the
Payout/*endpoints for performance-phase challenge accounts. See Simulated Withdrawals. - Pull-based bars —
get_next_bar()fetches the next historical bar overReplay/step; a real-time gateway would push bars to you instead. - Speed control —
read_speed(),STEP_DELAYandSPEED_FILEpace the replay from the Playground slider. - Any historical date — sessions run on the date range you choose, not on market hours.
Order/modify— not supported; use the cancel-and-re-place pattern described in Orders.
The base-URL change
The generated script reads its base URL from one environment variable:
API_URL = os.environ.get("TESTMAX_API_URL", "http://127.0.0.1:8087/api/sim")Inside the Playground, TestMax injects TESTMAX_API_URL for you. Running the script standalone against a hosted TestMax uses https://api.test-max.com/api/sim with a token from POST Auth/loginKey (see Authentication). Pointing it at another gateway that speaks the same schema is the same one-line change.
Reference
- Simulator API overview — every endpoint TestMax implements
- Authentication — how to obtain and use API tokens
- Orders — complete order placement documentation
- Positions — position management endpoints