Agentic Trading Index

What an agent needs from a broker API, and what it costs

Trading terminal showing an order book and broker API execution data
Photo by Rafael Minguet Delgado on Pexels

A duplicate 100-share order at $50 creates $5,000 of unintended exposure. A 2% move against it costs $100 before fees. That is the price of treating a broker API as a simple order button instead of part of the trading system.

For an unattended agent, the API must report what happened, not merely whether a request reached the broker. It must also support a safe response when a network call times out, a fill arrives late or a market-data stream drops.

The direct API charge may be zero. Execution, engineering and recovery costs are not.

Budget for execution, data and failure

Price the full order lifecycle

A useful cost model separates visible charges from execution quality and operating overhead. Typical market ranges vary by instrument, account type, venue and data entitlement. The figures below are budgetary ranges for retail and independent setups, not quotes or audited results for any named broker.

Cost itemTypical market rangeUnit and practical implication
US equity commission$0 to $0.005Per share, per side. A zero commission does not remove spread, slippage or regulatory charges.
US listed options commission$0.50 to $0.75Per contract, per side, with exchange and regulatory fees potentially added.
Liquid US equity spread and slippage$0.01 to $0.05Per share round trip in ordinary conditions. Small-cap or fast-market costs can be materially higher.
Major FX pair spread0.1 to 1.5 pipsTypical quoted range in liquid conditions. Commission structure and session affect the all-in cost.
Retail market data$0 to $150+Per month, depending on feed, exchange access and real-time entitlements. Professional use can cost more.
Basic execution infrastructure$20 to $300Per month for a small deployment, before engineering time, monitoring services or premium data.

Consider 20 round trips per session, 100 shares per side and 21 sessions a month. That is 84,000 traded shares per month. At $0.005 per share per side, commissions amount to $420. If average adverse execution costs another half-cent per share, the estimate adds $420. This simplified calculation excludes market impact, exchange charges and losses from strategy performance.

Include the cost of operating the agent

API access is often included with an account, but the integration still needs engineering and ongoing attention. A small deployment might budget several hours a month for review and maintenance, with more time after API changes, corporate actions or outages. At a loaded engineering rate of $75 to $200 an hour, even four hours of maintenance represents $300 to $800 a month.

Budget separately for:

  • Live and delayed data subscriptions, including exchange fees and user classification.
  • Hosting, logs, metrics, alert delivery and secure storage of credentials.
  • Order rejects, partial fills and market impact, measured against the strategy's expected edge.
  • Engineering time for broker changes, incident review and recovery tests.

For paper testing, a purpose-built environment such as agentic paper trading from $9.99 a month can help exercise order logic before risking capital. Paper fills still need cautious interpretation. They rarely reproduce queue position, live liquidity or the full cost of crossing a spread.

Require truth about orders and positions

Separate acknowledgement from execution

An HTTP success response usually means a request was accepted for processing. It does not prove that an order is open, filled or even still valid. The agent should model an order as a state machine, with explicit transitions such as pending submission, accepted, partially filled, filled, cancelled, rejected and expired.

Each submission needs a stable client order ID that the agent can reuse when retrying after a timeout. Without broker-supported idempotency or a reliable lookup by that ID, a retry can create a second order. The safe recovery path is to query open orders and recent executions before submitting again. Never infer that a request failed just because the client did not receive its response.

Make fills and account state reconcilable

Streaming updates are useful for low-latency reaction, but a stream can disconnect, repeat messages or deliver events out of sequence. REST snapshots help recover, but the two views can disagree briefly. Keep an internal event ledger and periodically reconcile it against broker orders, executions, positions, cash and buying power.

The API should expose enough fields to explain the account state:

  • Execution ID, order ID, timestamp, quantity, price, fees and liquidity or venue fields when available.
  • Remaining quantity, average fill price, rejection reason and cancel status.
  • Position quantity, cost basis, realised and unrealised profit and loss, cash and available buying power.
  • Instrument identifiers, trading status, tick size, lot size and session information.

Also check how the broker handles cancel and replace. Some APIs implement replacement as a new order after cancelling the old one.

During that interval, the agent may have no working order. Others preserve priority only in limited cases. Test the actual sequence and monitor both order IDs.

Latency benchmarks depend on geography, workload and endpoint design. For a retail API, a REST request and response often takes roughly 100 to 800 milliseconds in normal conditions; streaming updates may arrive in tens to a few hundred milliseconds. These are broad working ranges, not service guarantees. Measure median, 95th and 99th percentile latency, plus the time from acknowledgement to execution update. Averages conceal the delays that cause stale decisions.

Put risk controls at more than one layer

A strategy should not be the only component allowed to decide whether an order is safe. A separate execution layer can reject malformed or oversized orders before they reach the broker. Broker-side controls provide another boundary if the agent or its host process fails.

Set limits that can be checked mechanically:

  • Maximum order notional, share or contract quantity, and open orders per instrument.
  • Maximum gross and net exposure, use, daily loss and order count.
  • Allowed instruments, order types, trading sessions and price collars.
  • Freshness thresholds for prices and account state before an order is permitted.
  • A kill switch that blocks new orders and can cancel working orders without relying on the strategy process.

Use decimal arithmetic and the instrument's tick and lot rules. Reject prices that do not conform rather than rounding silently. Validate buying power against a recent account snapshot, then expect that snapshot to change before the broker processes the order. A local check reduces avoidable rejects; it cannot replace the broker's margin decision.

Rate limits are part of the risk design. Find out whether the broker counts requests, orders, cancels or all of them together, and whether limits are per account, key or endpoint. A typical retail API may allow anything from a few requests per second to tens per second, but published limits can differ from practical limits. Apply a token bucket, prioritise cancels and risk-reducing requests, and use bounded exponential backoff with jitter for recoverable errors. Do not retry a non-idempotent order submission blindly.

Test recovery, not just successful requests

A sandbox can confirm that a request is syntactically valid. It may not model partial fills, queue priority, throttling, stale data, market halts or account restrictions with live fidelity. Treat sandbox success as an integration check, not evidence that the agent is safe to leave unattended.

Before live orders, run tests that deliberately produce failure conditions:

  1. Drop the network after sending an order but before receiving the response. Confirm that recovery checks broker state before retrying.
  2. Deliver duplicate and out-of-order execution events. Confirm that the internal position changes once, in the right direction.
  3. Partially fill an order, then cancel or replace the remainder. Reconcile the final quantity and average price.
  4. Throttle requests and return authentication, buying-power and instrument errors. Confirm that the agent distinguishes retryable from terminal failures.
  5. Disconnect the market-data stream, let prices become stale and restore the connection. Confirm that trading pauses until state is refreshed.
  6. Restart the agent while orders are working. Rebuild its view from broker records rather than from an empty local process.

Record order intent, request ID, client order ID, broker order ID, response, state transitions and executions with timestamps. Avoid logging secrets or full credentials. Alerts should distinguish an agent that is idle by design from one that has stopped receiving data or cannot reconcile positions.

Start with shadow decisions or paper orders, then use small live size while comparing the agent's ledger to broker statements and execution reports. Set explicit acceptance thresholds for reject rates, reconciliation differences, stale-data duration and recovery time. A position mismatch should stop new risk-taking until the cause is known, not trigger a guess at a corrective order.

Broker APIs still tend to report whether a request was accepted; an unattended strategy needs to know whether it owns a position.

Frequently Asked Questions

What should a broker API provide for automated trading?

It should support reliable order submission, lookup, cancellation and replacement, with stable identifiers and detailed status updates. It also needs execution records, account and position data, documented rate limits and a way to recover after a disconnect.

How much does a broker API cost?

Many brokers include API access with an account, but data, commissions, spread, slippage and infrastructure add costs. Typical retail market data ranges from free or delayed feeds to $150 or more per month, while professional exchange access can cost more.

How should an agent retry a timed-out order?

Do not submit the same order again without checking broker state. Query by a stable client order ID or reconcile open orders and recent executions first, because the broker may have accepted the original request even if the response was lost.

What API latency is acceptable for an unattended trading agent?

It depends on the strategy and instrument. Retail REST calls commonly take about 100 to 800 milliseconds in ordinary conditions, but measure tail latency and execution updates under the deployment's actual network and load.

Can a broker sandbox prove an agent is safe for live trading?

No. A sandbox can check request handling, but often does not reproduce live liquidity, queue position, partial fills, throttling or all account restrictions. Test failure and recovery behaviour, then validate with tightly limited live orders.