At the end of a bad week, a developer studies a dashboard showing 312 accepted orders, a tidy equity curve and no API errors. The live account tells a different story: several limits never filled, two cancels arrived after execution, and fees erased the strategy's narrow edge.
The sandbox passed. The trading system did not.
A successful request is not a successful trade
Most broker sandboxes are built to test API integration. They answer useful questions: does authentication work, does a request meet the schema, and can the client read an order status? They often do not model the market well enough to answer a different question: what happens to this strategy's orders under live conditions?
The distinction matters for software that trades without a person watching. A response with HTTP 200 or an accepted status means the broker received or validated a request. It does not prove that the order reached a venue, joined a queue, traded at the displayed price or completed before the strategy acted again. Treating acceptance as execution evidence builds incorrect assumptions into position sizing, inventory and risk checks.
Sandbox behaviour can also be deliberately simplified. Simulations may fill a market order at the latest quote, fill a limit order as soon as its price touches the market, and reset account balances between sessions.
Those choices make basic development convenient. They also remove the friction that determines whether an unattended system behaves safely.
A green status checks the request. It does not certify the fill.
Start by separating three test claims in logs and reports:
- Interface claim: the client can authenticate, submit, amend and cancel requests.
- State claim: the client can reconcile broker updates with its own order and position records.
- Execution claim: the simulated fills and costs resemble the live instrument, route and order size closely enough for a particular test.
A sandbox can provide strong evidence for the first claim, partial evidence for the second and weak evidence for the third. A platform comparison such as Agentic Trading Index can help developers assess agent-facing trading tools, but any sandbox still needs testing against the intended strategy and instruments.
Fills, costs and queues are usually the missing layer
A fill model that ignores queue priority makes passive strategies look more reliable than they are. If a buy limit is placed at the best bid, a live order joins behind existing volume. It fills only if enough sell flow reaches it after earlier orders have traded or cancelled. A sandbox that fills every order when the quote touches the limit has discarded that competition.
Market orders have a different problem. A simulator may use a single quote even when the order is large enough to consume several price levels. Spread, market impact and fees then disappear from the recorded result. For a strategy with an expected gross edge of a few basis points, costs of even 2 to 5 basis points per round trip can change whether the system has an edge at all. The figures below are typical practitioner ranges for liquid electronic markets, not audited measurements or promises about a particular broker. Instrument, session, order size and route can move them substantially.
| Measure | Sandbox behaviour, typical range | Live behaviour, typical range | What the gap can hide |
|---|---|---|---|
| Market-order acknowledgement to fill | 0 to 100 ms, often immediate | 20 to 250 ms in liquid markets, with longer tails | Price movement during submission and routing |
| Limit-order fill at a touched price | Near 100% in simple simulators | Highly variable, often 0% to 50% for brief touches | Queue position and whether traded volume reached the order |
| Slippage for a small market order | 0 to 1 tick in quote-based models | 0 to 3 or more ticks in fast or thin conditions | Spread changes, depth and market impact |
| Partial fills | Often absent or uncommon | 0% to 30% of orders, depending on size and liquidity | Residual quantity, cancel timing and position exposure |
| Execution costs | Often zero or simplified | Typically commission plus venue, regulatory or financing charges | A strategy's net edge and realised cash balance |
Do not take these ranges as a conversion factor from simulation to live results. Use them to identify what the simulator leaves out.
If the sandbox reports zero fees, configure a separate cost model. If it cannot represent queue priority, do not use its passive-fill rate as a forecast.
Order state is where unattended agents fail
Execution errors are not limited to bad prices. A timeout after submission creates an ambiguous state: the broker may have accepted the order even though the client did not receive the response. Retrying blindly can create a duplicate.
A cancel response can race with a fill. A partial fill can arrive after the agent has already decided the order was cancelled.
These cases expose a common sandbox weakness. A clean request-response loop encourages code that assumes each action completes once and in order. Live APIs commonly deliver asynchronous events, temporary disconnects and updates that need reconciliation. The local order record must handle uncertainty without silently inventing a position.
Build a fault-injection test around each order lifecycle. For every test, record the client order ID, broker order ID, event timestamp, received timestamp, cumulative filled quantity and remaining quantity. Check that repeated events do not double-count fills and that a restart can recover the broker's current state.
- Submit an order, then drop the connection before the acknowledgement arrives. Reconnect and query by a stable client order ID before deciding whether to retry.
- Send a cancel while a partial fill is possible. Deliver the fill update before and after the cancel acknowledgement, and confirm that both event orders lead to the same final position.
- Replay a duplicate fill event and an out-of-order status update. The ledger should remain idempotent and should not move from a terminal state back to an earlier one.
- Restart the agent with an open order and a non-zero position. Reconcile broker state before allowing the strategy to submit another order.
If the broker sandbox cannot trigger these conditions, simulate them in the client transport or a test harness. That does not make fills realistic, but it tests whether the agent can survive uncertainty. Keep order intent, broker state and strategy state as separate records. This makes discrepancies visible instead of hiding them in a single status field.
Risk controls need realistic failure conditions
Sandbox balances and permissions can give false confidence about account-level controls. A simulated account may permit a short sale, ignore buying-power changes or accept an order that a live account would reject. It may also skip margin calls, borrow availability, trading halts, price bands and session restrictions. The omission is material when an agent sizes positions from available funds or submits orders across several instruments.
Test controls on the cases that create exposure, not just on the happy path. Useful scenarios include:
- Available buying power falls between signal generation and order submission.
- A market is halted or a quote becomes stale while the agent has an open order.
- A reject arrives after the strategy has reserved capital for the order.
- A rate limit is reached during a burst of cancels or status queries.
- The broker reports a position that differs from the agent's local ledger after a partial fill.
For each case, specify the allowed response. Should the agent stop new entries, cancel remaining orders, reduce exposure or raise an alert for a human? A system that cannot safely decide should fail closed. That usually means pausing new risk while continuing to reconcile open orders and positions. Do not assume the broker will enforce the strategy's own limits.
Use separate limits for order size, total gross exposure, daily loss and outstanding orders. Set them in the client as well as in any broker control that is available. Test that each limit works when the market-data feed is delayed and when a request times out. A control that depends on one clean API response is not a dependable control.
Turn the sandbox into a test, not a verdict
A broker sandbox is valuable when its scope is explicit. Use it to verify authentication, request formatting, permission handling and basic lifecycle integration.
Use a separate fill model or agentic paper-trading environment to exercise strategy logic, cost assumptions and event handling. For example, paper trading for agents can form part of that test workflow, but it should not be mistaken for a guarantee of live execution.
Keep a gap register for every behaviour the sandbox does not model. Give each entry an owner, a compensating test and a decision about whether live deployment depends on it. A short register might include:
- No queue position model, so passive fills are not used to estimate strategy returns;
- No partial fills, so the client is tested with injected cumulative-fill events;
- No realistic fees, so net performance uses a documented external cost schedule;
- No ambiguous submission outcome, so timeouts trigger lookup and reconciliation rather than automatic resubmission;
- No live buying-power checks, so conservative client-side exposure limits are enforced.
Record evidence at order level, not only as a daily profit curve. Useful fields include intended price, submitted price, acknowledgement delay, first-fill delay, average fill price, filled quantity, fees, reject reason and the market quote at submission and fill. Compare these fields across sandbox runs, paper runs and any tightly controlled live trial. Separate model assumptions from observations; otherwise a simulation can appear precise while relying on invented execution.
There is a practical trade-off. Making a simulator more realistic takes time and can create false precision if its queue or impact model lacks good data. Keep the model simple where evidence is weak, then stress the agent with adverse but plausible cases. A simulator should reveal where an agent breaks, not certify that it will earn money.
This week, add one fault-injection test that drops the acknowledgement after submission, then require the agent to reconcile the order before it can retry.
Frequently Asked Questions
What does a broker sandbox actually test?
It usually tests authentication, request formatting, permissions and basic order lifecycle integration. It may provide little evidence about live fills, queue priority, fees, slippage or account restrictions.
Can a broker sandbox predict live order fills?
Only if its fill model represents the relevant market mechanics, order size and route. Many sandboxes fill at a quote or price touch without modelling queue position, partial fills or market impact, so their fill rates should not be treated as forecasts.
How should an agent handle a timed-out order submission?
Do not retry blindly, because the broker may have accepted the first request. Query using a stable client order ID, reconcile broker state and submit again only when the original order is confirmed absent.