Skip to content
Back to App

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:

EndpointBehavior
Account/searchReturns account info
Order/placePlaces a trading order (fills against historical data in TestMax)
Position/searchOpenReturns open positions
Trade/searchReturns 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 pathsOrder/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 ControlReplay/start, Replay/step, Replay/end, Replay/jumpTo, Replay/play and Replay/pause. See Replay Control.
  • Simulated withdrawals — the Payout/* endpoints for performance-phase challenge accounts. See Simulated Withdrawals.
  • Pull-based barsget_next_bar() fetches the next historical bar over Replay/step; a real-time gateway would push bars to you instead.
  • Speed controlread_speed(), STEP_DELAY and SPEED_FILE pace 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