Two operators, opposite calls
Consider two teams testing the same strategy. The first sees every limit order fill at its requested price in the broker sandbox and approves unattended trading. The second treats that fill as evidence only that the API accepted a request, then blocks deployment until it has tested partial fills, cancel races and stale prices.
They made opposite calls from the same test because a sandbox can accurately check message formats while poorly representing execution. The gap is not necessarily deliberate deception. It is a mismatch between what the simulator models and what a live order depends on: available liquidity, queue position, market state, risk checks and event timing.
Use the sandbox to learn the API contract. Do not use its fills as a forecast of live performance. A 30-day test should map the differences, then turn the important ones into explicit limits on the agent.
The sandbox contract is narrower than it looks
Many environments match orders against a simplified book, fill at the requested price, or return a fill immediately after acceptance. That is useful for checking whether code handles a response. It says little about whether a live limit order would reach the front of a queue, fill only in part, or remain open as the price moves away.
Other gaps appear around state and failure. A cancel request can be accepted while the order has already filled. A websocket event can arrive after a REST response, or arrive twice after reconnect. Buying power, short-sale locates, margin, trading halts, auction rules and rate limits may be simplified or absent. Broker behaviour varies, so record what your specific environment documents and what you have actually observed.
Build around a durable order state machine, not a sequence of optimistic API calls. Store a unique client order ID, persist every request and response, and reconcile open orders and positions after disconnects.
Treat an acknowledgement as acknowledgement, not as a fill. Treat a cancel acknowledgement as a request outcome until order status confirms the terminal state.
Days 1-7: make the baseline reproducible
Start with a small, fixed test set: one liquid instrument, one less liquid instrument, a market order, a limit order, a cancel and replace, and a rejected request. Fix the strategy version, market-data source, clock and test window.
Save raw REST responses, websocket messages, timestamps and your internal state transitions. Without those records, a result cannot be compared later.
Use this numbered checklist to structure the month:
- Days 1-7: document the API contract and capture baseline request, response and order-event traces.
- Days 8-14: inject timeouts, duplicate messages, reconnects, rejects and cancel races.
- Days 15-21: estimate spread, fees, slippage and partial-fill effects with live market data and conservative assumptions.
- Days 22-26: run the agent in shadow mode, generating decisions without sending orders, and compare intended orders with current quotes and risk limits.
- Days 27-30: review failures, set deployment gates and, if approved, test only tightly capped live orders under active monitoring.
For every order, retain the signal time, quote time, submission time, acknowledgement time, fill time and final status. Calculate latency from your own timestamps, and record whether events came from REST or streaming. Check clock synchronisation too. A timestamp comparison is not meaningful if the machine clocks drift.
Days 8-14: test failure, not just success
Fault injection reveals whether the agent can recover without doubling exposure. Drop a connection after submission but before the response. On reconnect, query by client order ID before retrying. Deliver duplicate and out-of-order events to the local state processor. Delay a cancel response, then simulate a fill arriving before cancellation is confirmed. The expected outcome is a reconciled position, not a guessed one.
Test rate limits and authentication expiry with bounded retries and backoff. An agent that retries every failed request immediately can turn a short outage into a longer one, or submit duplicate orders if the original request succeeded upstream. Define which errors are retryable, which require a fresh account and order query, and which must stop trading.
Track concrete measures: duplicate submissions, unreconciled orders, event-processing lag, rejected orders by reason and time to recover after disconnect. A practical release gate is zero unexplained position or order mismatches across the test set. Set a maximum acceptable event lag from the strategy's holding period and execution method, rather than copying a generic millisecond target.
Days 15-21: model the costs the simulator skips
Compare the sandbox fill with the quote available when the order would have been sent. For limits, record whether the market traded through the price and how much displayed volume was available.
A trade at your limit does not prove your order would have filled: queue priority and hidden liquidity matter. For marketable orders, estimate the fill against the opposite side of the book, then apply a conservative slippage allowance.
The figures below are typical market ranges for planning, not quotes or audited results. They vary by instrument, venue, order size, session and market conditions. Treat them as a starting point for sensitivity tests, not as constants in production.
| Cost component | Typical market range | What a sandbox may mask | What to record |
|---|---|---|---|
| US listed equity commission | $0 to $0.005 per share, with venue and regulatory fees potentially additional | Fees may be omitted or shown only at account level | Fees per fill and per order |
| Liquid equity spread | About 1-5 basis points in ordinary conditions; wider in less liquid or stressed markets | Fills at the midpoint or requested limit | Arrival price, fill price and spread at submission |
| FX major-pair spread | About 0.1-1.5 pips in liquid hours; 1-5 or more around rollover or stressed periods | Fixed spread, no widening, or no slippage | Spread by session and order size |
| Futures brokerage fees | Roughly $0.50-$3.50 per side per contract, before some exchange or clearing charges | One combined fee or no fee detail | All-in fees per contract and venue |
| Market impact and slippage | From a few basis points to 20 or more for small orders, with much wider outcomes possible in thin or fast markets | No queue, depth consumption or price movement | Implementation shortfall by size and volatility |
Run sensitivity tests at the low, middle and high end of the applicable range. If the strategy only works at the low end, the sandbox has not established that it is viable. A separate paper-trading harness, such as agentic paper trading, can provide another place to test the agent's order handling, but it remains a simulation rather than proof of live fills.
Days 22-30: gate live deployment
Use shadow mode to compare each intended order with the live quote, spread, available depth and account limits. Record what would have been sent, what the conservative execution estimate would be, and why any order would have been blocked. This catches differences between strategy logic and operational controls before real exposure begins.
Write gates that can be checked by software. For example: no trading if market data is stale beyond a strategy-specific threshold; no new order while an earlier order has unknown status; cap notional, position size and daily loss; stop on repeated rejects or a reconciliation mismatch. Make the kill switch accessible outside the agent process, and test that it blocks new orders while still allowing cancellation and status checks.
A 30-day pass is not a guarantee of safe execution. Start live only if the risk owner approves the limits and the agent can fail closed when state is uncertain. If a small, supervised pilot is permitted, keep order size low, compare actual fills with the cost model, and stop at once if behaviour falls outside pre-set tolerances.
Stop doing these things:
- Counting accepted requests as successful fills.
- Retrying an order before checking whether the first request reached the broker.
- Using sandbox fill prices as live execution estimates.
- Allowing the agent to trade when order or position state is uncertain.
Frequently Asked Questions
Why do broker sandboxes show unrealistic fills?
Many use simplified matching rules and do not model queue position, depth consumption or market impact. A sandbox fill can confirm that your code handles a fill event, but it is not evidence that a live order would fill at that price.
Can I test a trading bot in a broker sandbox?
Yes, use it to test authentication, request formats, order-state handling and basic error paths. Separately test partial fills, reconnects, duplicate events and conservative execution costs, since the sandbox may not reproduce them.
How long should broker sandbox testing take?
A 30-day plan can provide time to establish a baseline, inject failures, estimate costs and run shadow tests. Passing the plan does not guarantee safe trading; release criteria should depend on the strategy, instruments and operational risk.
What should I test before retrying a timed-out order?
Query order status using a stable client order ID before sending another request. The broker may have accepted the original order even though your process never received its response.
How do I estimate live trading costs from paper results?
Compare intended prices with contemporaneous quotes and model spread, fees, slippage and partial fills using conservative ranges. Paper results alone do not reveal queue priority or the market impact of your order size.