Skip to content
Back to App

Error Codes

This page documents the error codes you may encounter when using TestMax. These codes appear in API responses, the output log during backtests, and occasionally in the UI when an operation fails.

TopStep Simulator API error codes

The TopStep Simulator API (/api/topstep-sim/) returns errors as {"success": false, "errorCode": N, "errorMessage": "..."} — with HTTP status 200 (rate limiting is the exception: a real HTTP 429). The codes are contextual — the same number can mean different things on different endpoints — so always read errorMessage:

CodeUsed forTypical messagesResolution
0SuccessNo action needed
1Missing resources"Account not found", "Contract not found", "Instrument not found"; on Auth/validate: "Invalid session"Check the accountId/contractId you sent; re-authenticate if the session is invalid
2Invalid state or parameter"Order not found", "Position not found", "No active replay session", "startDate required", "Unit invalid", "Invalid time range", "Account is not in funded phase"; on Order/place: the engine’s rejection reason (e.g., insufficient margin)Fix the parameter, or start a replay session first; for order rejections, read the reason
3Auth failures and unsupported operations"Invalid credentials", "Invalid or expired token", "Order modification not supported in simulator", "Invalid payout amount", "Unit number invalid"Re-authenticate; use cancel + re-place instead of Order/modify
4Account/rule violations"Account violation" (terminal challenge), "Payout not eligible...", "Limit invalid"A passed/violated/ended challenge cannot keep trading — start a new one; check payout eligibility first
5Close/payout failures"Invalid close size", close-order rejection reasons, "Payout failed — please retry"Check the close size against your position; retry payouts
6Partial-close rejectionsThe engine’s rejection reasonRead the reason and adjust
7Order/session validation"Invalid order size", "Invalid order type or side", "Failed to start replay"Size must be an integer from 1–1000; check enum values; check the replay date has data
9Pro required"Pro subscription required for TopStep Simulator API"Upgrade to Pro from Plans & Pricing
99Internal error"Internal server error"Retry after a brief wait. If persistent, contact support
429Rate limited"Too many requests" — arrives as a real HTTP 429 with a Retry-After headerWait the indicated seconds. Limits: login 10/15 min per IP and 5/15 min per email; History/retrieveBars 20/min per account

Playground API — HTTP status codes

The Playground API (/api/playground/) does not use the errorCode envelope. Errors are real HTTP statuses with a JSON body of {"error": "message"}:

StatusMeaningCommon scenarios
200OKRequest succeeded
400Bad RequestEmpty strategy code, script over 200 KB, missing instrument/startDate, invalid or too-large date range (max 2 years), strategy limit reached (100)
401UnauthorizedNot logged in — session cookie is missing or expired
403ForbiddenAlgo Playground requires a Pro subscription
404Not FoundUnknown strategy ID or execution ID (or one owned by another user)
429Too Many RequestsYou already have a backtest running, the server is at its concurrent-run capacity, or you exceeded 100 requests/min on CRUD endpoints — the Retry-After header says how long to wait
500Internal Server ErrorAn unexpected server error occurred. Retry after a brief wait
502Bad GatewayThe server is temporarily unavailable, often during deployments
503Service UnavailablePlayground temporarily unavailable, maintenance, or high load
504Gateway TimeoutThe request took too long to process. Reduce the scope (e.g., smaller date range) and retry

Common error patterns

Error during backtest execution

If you see errors in the output log during a backtest, they typically follow this format:

[ERROR] API Order/place: 400 Invalid size

The format is: [ERROR] API {endpoint}: {HTTP status} {error message}

Common backtest errors:

Error messageCauseFix
Invalid order sizeOrder quantity is missing, 0, negative, non-integer, or over 1000Check your strategy logic for position sizing
Invalid order type or sideUnknown type or side enum valueUse type 1–4 and side 0–1 — see Enums & Types
Already running a backtest. Stop it first.A previous execution is still active (HTTP 429)Stop it via the UI or /stop, or wait for it to finish
Backtest stops after 30 minutesExecution exceeded the 30-minute timeoutReduce date range or increase timeframe
Script too largeStrategy code exceeds 200 KBReduce script size — see Common Issues

Authentication errors after session expiry

If you receive error code 3 (Invalid credentials) or HTTP 401 unexpectedly during normal use, your session token has likely expired. This happens if:

  • You have been inactive for an extended period
  • Your subscription status changed
  • You logged in from another device

Solution: Refresh the page or log out and log back in. Your trading data and settings are preserved.

Concurrent execution errors

An HTTP 429 with the “Already running a backtest” message indicates you are trying to start a second concurrent execution. TestMax enforces a limit of one active backtest per user (and a server-wide cap across all users).

Solution: Stop the existing execution first, or wait for it to complete. If you believe no execution is running, wait a moment for the stale-process auto-cleanup, then try again.

Reporting errors

If you encounter an error that is not documented here or that persists after following the recommended resolution:

  1. Note the exact error message and error code
  2. Record the date, time, instrument, and timeframe you were using
  3. Copy any relevant output log content
  4. Contact support via the in-app help button or email

Pro subscribers receive priority support response times.