A stale feed turns into a live loss
A 0.5% adverse move on a $25,000 position costs $125 before fees. In this hypothetical case, an intraday trading agent misses a feed update, keeps quoting from an old price and takes four minutes to stop.
The account has $50,000 of equity, with a $25,000 cap on that instrument. The loss is manageable; the failure is that the system did not recognise a condition it was designed to contain.
A kill switch should make that fault boring. It needs to stop new risk, deal with resting orders and establish the actual position from broker or venue state. A local flag that tells the strategy to pause is not enough if its last order is still working. Nor is sending a flatten order enough if the agent cannot tell whether that order filled.
Give the switch explicit states, such as active, tripped, cancelling, reconciling, and halted. Record the trigger, timestamp, observed position and action results. The agent should not resume just because the feed recovers or a process restarts.
Define what the switch does
Separate the decision to halt from the recovery actions. A data fault may call for cancelling open orders and holding an existing position for a separate risk process to handle. A hard exposure breach may require flattening. That choice depends on the instrument, liquidity and strategy; blindly selling everything can make a bad state worse in a thin market.
For the example account, specify whether the switch:
- Blocks new orders from every strategy sharing the account or only the affected instrument;
- Cancels working orders, then checks for late fills before calculating exposure;
- Flattens only when a defined risk rule requires it, using a bounded order policy;
- Disables automatic restart and requires a fresh health check before re-entry.
Use a central risk service or broker-side limits where available. A strategy process can fail, lose its connection or ignore its own flag.
A separate component that checks account-wide exposure reduces that single-process failure mode. Keep the emergency path small, observable and independent of the strategy's normal order loop.
Choose trip conditions that can be measured
Set thresholds against the data the system can actually observe. A feed's event time can be old while messages are arriving, so compare both source timestamps and local receive times.
Track sequence gaps, heartbeat age and whether the price is valid for the instrument and session. Thresholds should reflect the feed's normal cadence, not a convenient round number.
Common conditions to evaluate include:
- Data health: quote age or heartbeat exceeds its limit, sequence numbers skip, or a required instrument loses updates.
- Order health: acknowledgement or cancel response times out, rejects exceed a rolling threshold, or broker and local order states disagree.
- Exposure: position, working-order notional or combined account risk passes a hard cap. Count unfilled orders as potential exposure.
- Loss: realised plus unrealised loss reaches a session limit, with fees and open-order risk included where practical.
- Process health: clock drift, repeated restarts, risk-service failure or an unexpected strategy version makes safe order handling uncertain.
Use separate warning and trip levels. For example, alert when quote age reaches 1 second and halt at 3 seconds if the feed normally updates several times a second. Treat these as configuration starting points, not universal thresholds.
Add hysteresis: recovery might require 30 seconds of clean data, no unresolved orders and a fresh position reconciliation. This prevents rapid stop-start behaviour around a boundary.
Put the financial exposure on the page
Thresholds become easier to review when their possible cost is visible. The figures below are typical market ranges for liquid instruments in ordinary conditions, not audited results or guarantees. Dollar illustrations use $25,000 of notional and exclude commissions, financing and market impact beyond the stated range.
| Failure or action | Typical market range | Illustrative cost or exposure |
|---|---|---|
| Adverse move while stale data goes undetected | 0.1%-0.5% move on the position | $25-$125 loss on $25,000 |
| Extra slippage during a market-order exit | 1-10 basis points in liquid conditions | $2.50-$25 on $25,000 |
| Part of a resting order fills after a cancel request | 5%-20% of order notional remains exposed | $1,250-$5,000 of exposure |
These ranges can widen around news, opening and closing auctions, thin books or venue disruption. A limit order can constrain price but may leave the position open. A market order seeks execution but can pay through the spread. The kill path should state which risk it accepts, and log actual fills so a later restart does not assume the intended exit happened.
Checklist for a safe trip
Before enabling live orders, walk through this sequence in a broker sandbox and in paper trading. Agentic Trading Index offers agentic paper trading from $9.99 a month for exercising software-driven order flows. A paper environment can test state transitions and recovery logic, but it cannot prove live liquidity or venue behaviour.
- Set per-instrument and account-wide exposure caps. Count positions plus the maximum plausible fills from working orders.
- Define measurable data, order, loss and process triggers. Store thresholds as versioned configuration, not scattered constants.
- On a trip, block new order submissions before attempting cancellation or liquidation.
- Send cancels with stable client order identifiers. Treat timeouts as unknown state, not proof of failure or success.
- Query open orders and positions from the broker, reconcile late fills, then decide whether flattening is required.
- Make repeated trip messages safe to process. Preserve the original trigger and record each action's result.
- Require clean data, reconciled orders and an explicit restart policy before the system can resume.
- Test partial fills, delayed acknowledgements, disconnects during cancel, process restarts and simultaneous triggers.
Test the failed action, not just the trigger
A unit test that confirms stale data sets a halt flag covers only the first step. Inject a delayed cancel response, then deliver a fill that occurred before the cancel reached the venue. Confirm that the position is recalculated and the agent does not send a second exit based on an obsolete quantity. Repeat with a restart between each action.
Measure time from trigger to blocked submissions, cancellation requests, confirmed order state and reconciled exposure. These are different timings. A system may stop submitting in milliseconds while an order remains live for seconds.
Keep alerts for every unresolved order and escalate when reconciliation cannot complete. In that state, the safe behaviour is usually to remain halted, not to guess.
Run the same scenarios after changing broker adapters, order types or risk configuration. A switch that worked for a single instrument can fail when several strategies share an account or when the broker reports positions at a different granularity. The mistake most readers will still make is treating a kill switch as one cancel-all call, rather than a verified state transition that proves exposure is bounded.
Frequently Asked Questions
What should trigger a trading agent kill switch?
Typical triggers include stale or inconsistent market data, unresolved order acknowledgements, excess exposure, a session loss limit and failures in the risk service. Define each trigger using observable data and set thresholds to match the feed and instrument.
Should a kill switch cancel orders or flatten positions?
It should first block new risk and cancel working orders, then reconcile actual fills and positions. Flatten only when a separate, explicit risk rule calls for it, since an immediate market exit can add slippage or be unsuitable for an illiquid position.
How stale should market data be before an agent stops trading?
There is no universal cutoff. Use the feed's normal update cadence and instrument liquidity to set a warning threshold and a harder trip threshold, then test those values against delayed messages and sequence gaps.
How do I test an automated trading kill switch?
Simulate stale feeds, rejected orders, delayed cancels, partial fills, disconnects and process restarts. Check that the system blocks new submissions, reconciles broker state and stays halted when an order or position remains uncertain.