Agentic Trading Index

Kill switches for trading agents: a 30-day implementation plan

Trading terminal with a clearly labelled emergency stop button, illustrating kill switches for automated trading
Photo by Bibek ghosh on Pexels

A kill switch is a control that blocks an automated trading system from creating or maintaining risk when a defined condition is met.

That definition sounds binary, but a live system cannot simply stop all activity without considering what is already in flight. A submit request may have timed out after reaching the broker. A cancel may be pending while an order partially fills. A strategy that stops sending instructions can leave working orders and open positions unattended. Design the switch as a controlled transition between operating states, with explicit rules for orders, positions and recovery.

The aim is not to prevent every loss. It is to limit the damage from a strategy behaving outside its permitted envelope, a broken data feed, or an execution path that no longer provides reliable state. Start with the actions the system must take, then choose trip conditions that are observable and testable.

Define what the switch controls

Decide whether a trip applies to one strategy, one account, or every strategy using the same broker credentials. A strategy-level stop contains a local fault. An account-level stop protects total exposure when several agents share capital.

A global stop is appropriate for a broker outage, compromised credentials or corrupted shared market data. Keep these scopes separate in configuration and logs so a narrow fault does not automatically disable unrelated trading.

Specify the response for each scope. A useful state model has four stages:

  1. Warn: record the condition and notify the monitoring service. The strategy may continue trading.
  2. Inhibit: reject new risk-increasing orders, including replacement orders that would increase size or worsen exposure.
  3. Cancel: request cancellation of working entry orders. Decide separately whether protective stops and other risk-reducing orders should remain active.
  4. Flatten: reduce or close positions only if that action is explicitly configured for the instrument and account.

Cancellation and liquidation are not interchangeable. Cancelling all orders may remove a stop that was protecting an open position. Flattening with market orders may incur substantial slippage in a thin book, while limit orders may not fill. A conservative default is to inhibit new exposure, cancel entry orders, preserve protective orders where possible, and require a separate policy for liquidation. For each policy, define what happens if the broker rejects the action or the connection is down.

Implement the stop path outside the strategy process. If the strategy crashes, hangs or consumes its own event loop, an in-process flag will not help. A risk service or execution gateway should enforce the latch before an order reaches the broker. Persist the latched state so a restart cannot silently clear it. The strategy may request a stop, but it must not be able to clear a global stop by itself.

Choose trip conditions that can be measured

Use a small set of independent signals. Include hard limits on exposure, loss and order size, plus health checks for the data and execution paths. A single signal rarely describes the whole fault: a market-data feed can be stale while the broker connection still answers, and a strategy can lose money without malfunctioning.

Risk and order conditions

Express limits in account currency and in a normalised unit such as a percentage of equity. Apply checks before order submission and after fills. Pre-trade checks catch oversized requests; post-fill checks catch exposure that changes through partial fills, price moves or positions held by other strategies. Use the broker-reported position as a reconciliation input, not the sole source of truth: broker updates can be delayed or incomplete.

Define loss as a specific calculation. For example, combine realised and unrealised profit and loss since a fixed session boundary, subtract known fees, and state how funding, deposits and overnight positions are treated. A high-water-mark drawdown is a different measure from a daily loss cap. Avoid vague triggers such as "large loss" or "unusual position".

System and execution conditions

Measure market-data age per instrument, not only by a process-wide heartbeat. Measure order acknowledgement time from submission to broker acknowledgement, and track rejects, disconnects and unresolved requests. A successful HTTP response does not prove that the intended order is live. Track order state until it is confirmed, rejected, cancelled or reconciled against a fill.

The table gives typical ranges for initial testing, not universal limits or audited results. Calibrate them against the strategy, venue, instrument liquidity, account size and trading session. Limits imposed by a broker, venue or regulation take precedence.

SignalTypical range for a tripInitial response
Single order notional0.25% to 1% of account equityReject the order and latch the strategy if repeated
Gross exposure80% to 100% of the configured strategy limitInhibit orders that add exposure
Session loss1% to 3% of allocated capitalStop new entries and cancel working entry orders
Market-data age2 to 10 seconds for liquid products, longer only where the feed warrants itBlock orders using the stale instrument data
Order rejects3 to 5 rejects in 1 minutePause the affected strategy and inspect reject codes
Acknowledgement latency2 to 5 times the normal baseline, sustained for 30 to 120 secondsStop retries that could create duplicate orders

A threshold needs a time window and a reset rule. Three rejects in a minute is different from three rejects over a trading week. For noisy signals, require a sustained breach or apply hysteresis, such as tripping above a limit and only clearing after the value remains comfortably below it for a defined period. Hard caps on order size or account exposure should not use hysteresis that permits a breach.

Make the shutdown path safe under failure

Latch before making broker calls

When a condition trips, persist the latch first. Then block new orders locally before attempting cancellation. This order matters: if cancellation stalls, the strategy must still be unable to add fresh exposure. Record the trigger, observed values, instrument, account, timestamp, source event and version of the limits in effect. Those details make a trip explainable after the fact.

Treat a request with an uncertain outcome as unresolved, not failed. If an order submission times out, query by client order ID or reconcile against broker open orders before retrying. A blind retry can create a second live order.

Use stable client IDs where supported, and make cancellation and replacement logic idempotent. If the broker does not support reliable lookup, stop sending orders on that connection and escalate to a separate reconciliation path.

Make the shutdown path resilient to rate limits and partial failures. Track each cancel request independently. If the broker rate-limits cancellations, apply bounded backoff and keep the inhibit latch active.

Do not report "stopped" merely because cancel requests were sent. Report the status of each order as confirmed cancelled, still open, filled, rejected or unresolved.

Separate stopping from re-arming

A trip should latch until a defined recovery procedure clears it. Require healthy data, a working broker connection and a fresh comparison of local orders and positions with broker state. For high-impact account or global stops, make re-arming a deliberate operator action. A system can still be unattended during trading without being allowed to restart itself after evidence of a fault.

After recovery, restore risk gradually. For example, start with a reduced order-size cap and lower exposure limit, then raise them only after a clean observation period. The precise steps depend on the account and strategy, but write them down in configuration rather than relying on an operator to remember informal rules. Use alerts to report the trip and recovery state; alerts are not a substitute for enforcing the stop in the order path.

Implement and test it in 30 days

Use the first five days to map every route from signal generation to broker order, including scheduled jobs, retry queues and manual tools. Inventory accounts, strategies, instruments, client IDs and existing broker-side limits. Write down which process owns each order and position view. Set the first version of the trip policy in a reviewed configuration file, with separate limits for strategy, account and global scope.

On days 6 to 10, instrument the system. Capture data age, order acknowledgement time, rejects, cancel outcomes, position differences and risk-limit utilisation. Emit structured events for every state transition. Replay normal sessions to estimate typical latency and reject rates before setting health thresholds; a limit that trips during ordinary venue delays will be ignored or routinely reset.

On days 11 to 17, build the latch, order gate and reconciliation flow. Test local behaviour without broker access first. Then test broker requests with small or simulated orders. Keep the stop mechanism independent from the strategy worker, and make a process restart retain the latched state. If repeatable fault tests are needed, agentic paper trading is available from $9.99 a month.

Use days 18 to 24 for failure injection. At minimum, test these cases:

  • Kill the strategy process while entry orders are working.
  • Delay or drop an acknowledgement after a submit request reaches the broker.
  • Return a partial fill while a cancel request is pending.
  • Send stale prices, duplicate events and out-of-order updates.
  • Disconnect the broker, trigger rate limits and restore the connection.
  • Restart the risk service and confirm that the latch and unresolved orders survive.

For every test, record whether new orders were blocked, whether existing orders were handled according to policy, and whether local state reconciled with the broker. A test passes only when the final state is known. "The process stopped" is not a passing result if a working order remains unaccounted for.

On days 25 to 30, run in shadow mode alongside the live system without allowing the new controls to cancel orders. Compare proposed trips with actual events and inspect false positives and missed conditions. Then enable enforcement for one strategy with reduced limits, a small order cap and a clear rollback procedure.

Expand scope only after reviewing trip logs and reconciliation results. Keep the original broker-side limits in place as an independent layer.

Stop doing these things:

  • Stop treating a process exit as proof that trading has stopped.
  • Stop retrying timed-out order submissions without checking broker state.
  • Stop clearing a latched stop automatically on restart.
  • Stop using one unexplained threshold for every strategy and instrument.

Frequently Asked Questions

What should a trading kill switch do first?

It should latch the stop and block new risk-increasing orders before making broker calls. It should then handle working orders and open positions according to an explicit policy, while recording whether each action succeeded.

Should a kill switch automatically close every open position?

Not by default. Market orders can create significant slippage, and cancelling all orders can remove protective stops. Define liquidation rules separately for each account or strategy, including what to do when the broker is unavailable.

How should I test a kill switch before live use?

Inject failures such as delayed acknowledgements, partial fills, stale data, broker disconnects and process restarts. Verify that new orders are blocked and that every working order and position reaches a known reconciled state.