Gateway Compatibility
The Simulator API supports common futures-gateway request shapes. Changing TESTMAX_API_URL alone does not migrate a bot. TestMax needs its own authentication, replay session and pull-based bar loop.
What the schema shares
TestMax implements the same endpoint names, request bodies and response shapes as the gateway schema:
| Endpoint | Behavior |
|---|---|
Account/search | Lists simulator-compatible Challenge Mode accounts |
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.
Adapting a bot
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). Then adapt the replay lifecycle:
- Start a session with
Replay/startand use the returned account and contract IDs. Inside the Playground, the session is pre-created and those IDs are supplied for you. - Advance historical bars with
Replay/stepinstead of waiting for a live market-data feed. Handle loading refusals and the end of the data window. - Close positions and call
Replay/endwhen the run finishes.
See Replay Control for the request and response fields. Moving a Playground strategy to another gateway also requires replacing these TestMax-only lifecycle calls and its bar source.
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