"Would we know within a minute if the agent started sending duplicate orders?" Ask the team that, then test the answer. Monitoring an unattended strategy means detecting broken state, stopping new risk and preserving enough evidence to understand what happened. A green process status or a profitable P&L line does not prove that orders are safe.
Define what should wake someone
Start with the conditions that require action, not a dashboard full of metrics. Assign each condition an owner, a response time and an automated fallback.
A stale quote may block new entries. A position mismatch may pause the strategy and page the on-call operator. A breach of a hard exposure limit may cancel working orders, with flattening handled by a separate, explicit policy.
Write down the agent's expected operating envelope: instruments, trading hours, maximum order size, gross and net exposure, and permitted order types. Include limits at both strategy and account level. A strategy-level cap cannot protect an account if another process shares the same buying power.
- Page: unexplained position mismatch, repeated rejects, exposure-limit breach, or no broker heartbeat while orders remain live.
- Pause new orders: stale market data, a sequence gap, rate limiting, or uncertain order status after a timeout.
- Record without paging: normal fills, low-severity latency changes and expected session transitions.
Keep the response policy executable. "Check the logs" is not a policy. State whether the system stops submitting, cancels open orders, attempts a position close, or waits for a human. Cancellation and liquidation are different actions: a cancel can leave an existing position exposed, while a market close can incur substantial slippage in a thin market.
Alert on uncertainty in account state before it becomes exposure.
Instrument the full order lifecycle
Give every intended order a durable internal ID and preserve the broker's client order ID and order ID. Record the strategy decision, instrument, side, quantity, limit or stop price, timestamp, request payload, response, subsequent updates and final state. Keep timestamps in UTC and synchronise hosts with a reliable time source. Without this chain, a timeout followed by a retry can look like two unrelated orders.
Model order state explicitly: created, submitted, acknowledged, partially filled, filled, cancelled, rejected or unknown. Treat "unknown" as a real state, not as permission to resubmit. On a timeout, query by client order ID or reconcile against the broker's order list before retrying. Use idempotency keys where the API supports them, but do not assume a client library makes retries safe.
Consume broker streams for prompt updates, then reconcile them against REST snapshots. Streams can disconnect, deliver duplicate events or skip a sequence. Track the last sequence number and connection heartbeat.
Fetch open orders, positions and recent executions on reconnect, and compare broker state with the agent's internal ledger. A 15 to 60 second reconciliation interval is a typical starting range for active systems, tightened where the venue and rate limits allow.
Log market-data age at decision time, not only the feed's connection status. A connected feed can still deliver delayed or frozen prices. Record quote timestamp, receive timestamp, decision timestamp and submit timestamp separately. This lets the team distinguish stale input from slow strategy computation or a slow broker response.
Set useful thresholds, not decorative alerts
Choose thresholds from the instrument, venue, session and strategy cadence. The figures below are typical starting ranges for monitoring, not universal market standards.
Test them against normal operation and known failure cases. A threshold that pages on every routine spread widening will be ignored; one that waits for a large daily loss may detect a control failure too late.
| Signal | Typical starting range | First response |
|---|---|---|
| Market-data age at decision | 1 to 3 seconds for liquid instruments; 5 to 15 seconds for slower or thinner markets | Block new entries when the strategy's freshness limit is exceeded |
| Order acknowledgement time | Alert after 1 to 2 seconds; tune to venue and order type | Mark status unknown, query broker state, do not blindly retry |
| Reject rate | Review above 0.5% to 2% over a rolling 50 to 200 orders | Group rejects by code, pause if repeated errors imply invalid pricing or permissions |
| Position reconciliation | Every 15 to 60 seconds during active trading, plus on reconnect | Pause new orders on any unexplained quantity mismatch |
| Exposure headroom | Alert at 70% to 90% of a configured hard limit | Reduce order size or block entries before the hard limit is reached |
Use rolling windows and minimum sample sizes. A single reject among five orders is a 20% rate, but it may be less informative than ten rejects of the same type in a minute. Pair percentages with counts, error codes and instrument context. For slippage, compare fills with the decision-time mid or a defined arrival price, and separate spread cost from price movement. Typical slippage varies widely by instrument and order size, so set alerts from the strategy's own tolerated cost rather than borrowing a generic basis-point limit.
Keep alerts actionable. Send a concise message with account, strategy, instrument, current position, working orders, triggering threshold and runbook link. Route critical events to a monitored channel with an escalation path. A notification that only says "risk alert" forces the recipient to reconstruct the incident before acting.
Run a five-day monitoring drill
Use a paper account or a controlled test environment for fault injection. Agentic paper trading from FX Tech can provide a place to exercise order workflows without placing live orders. Paper results do not prove live execution quality, but they are useful for checking whether state transitions, alerts and recovery logic work as designed.
- Monday, baseline: capture one normal session. Measure quote age, decision-to-submit time, acknowledgement latency, reject codes, fill updates and reconciliation differences. Confirm that every order can be traced from intent to terminal state.
- Tuesday, disconnect: interrupt the market-data stream and broker stream separately for 30 to 90 seconds. Confirm that stale data blocks entries, reconnect triggers a state comparison, and duplicate events do not create duplicate fills in the internal ledger.
- Wednesday, ambiguous submit: delay or drop the response after an order reaches the broker. Verify that the agent queries by client order ID and resolves the order before any retry. Check that the alert shows the request ID and current broker state.
- Thursday, risk breach: use a small paper limit, then trigger it with a sequence of orders or a simulated position change. Confirm that the system blocks additional risk, handles working orders according to policy and pages the right person.
- Friday, recovery and review: restart the agent with open orders and a non-zero position. Reconcile from broker snapshots, inspect the incident timeline, and record any alert that was missing, late or noisy. Turn each defect into a test that runs before deployment.
Do not test a kill switch only by checking that a button changes colour. Verify its scope, permissions and result: does it stop one strategy or the whole account, cancel working orders, and persist through a process restart? If it can flatten positions, test that behaviour separately with a small, controlled quantity and document the execution risks.
Keep evidence and remove noise
Keep structured logs long enough to investigate broker disputes and delayed incidents. Include a correlation ID across strategy, execution service and alerting.
Store raw broker responses as well as parsed fields, with credentials and personal data removed. Make log writes resilient to brief network failures; losing the exact response during an outage can erase the evidence needed to distinguish a rejected order from an unacknowledged one.
Review monitoring after each strategy, broker or API change. New order types, changed rate limits and symbol mapping updates can invalidate assumptions. Put alert thresholds and kill-switch behaviour in version control, and add a deployment check for missing limits. If an alert has no clear owner or response, either define one or remove it.
Stop doing these things:
- Stop treating a live process or connected socket as proof that trading is healthy.
- Stop retrying timed-out order submissions before checking broker state.
- Stop paging on metrics that do not prescribe an action.
- Stop relying on end-of-day P&L to reveal intraday control failures.
Frequently Asked Questions
What should I monitor for an unattended trading agent?
Track market-data freshness, order state transitions, broker acknowledgement time, rejects, fills, positions and exposure limits. Also monitor stream heartbeats, sequence gaps and whether alerts reach an accountable operator.
How often should a trading agent reconcile positions?
A typical starting range is every 15 to 60 seconds during active trading, with an immediate reconciliation after reconnects or uncertain order responses. Adjust the interval for broker rate limits, strategy speed and the cost of an undetected mismatch.
What should an agent do when an order request times out?
Treat the order status as unknown and query the broker using the client order ID or another reliable identifier. Do not submit a replacement until the original order is resolved, since the first request may have reached the venue despite the missing response.
Should a kill switch cancel orders or close positions?
Those are separate controls and should have separate, tested policies. Cancelling working orders may leave existing exposure in place, while closing positions can cause slippage, so define the intended behaviour for each failure condition.