In week one, build a record of every decision, order and risk check, then prove that a separate monitor can detect a dead agent. By week six, the aim is not a prettier dashboard. It is a system that has survived several weeks of unattended operation, including deliberately injected faults, with clear evidence for every alert and intervention. The first 30 days establish that control; the following two weeks expose gaps that a short test can miss.
Define what the monitor must know
Monitoring should answer three questions quickly: what did the agent intend to do, what did the broker do, and does the account still match the agent's risk state? A process heartbeat alone answers none of these. The agent can be alive while using stale prices, repeating a rejected order or holding a position it failed to reconcile.
Give each decision and order a stable correlation ID. Record UTC wall-clock time and monotonic elapsed time, strategy and model version, instrument, signal inputs, target position, risk checks, order parameters, broker order ID, acknowledgements, fills, cancels and the resulting position. Keep decision records immutable. Redact credentials and avoid logging account secrets.
Run the monitor outside the agent process, ideally in a separate service or failure domain. It should consume events and query the broker independently. If the agent stops sending heartbeats, cannot reach the broker, or disagrees with the broker's position, the monitor must be able to stop new orders without relying on the agent to cooperate.
Days 1 to 7: build the event trail
Correlate intent with broker state
Start with a read-only monitor. On days one and two, define the event schema and risk invariants.
For example, a strategy may not exceed a position limit, submit a second entry while an equivalent order is pending, or trade on a quote older than its configured maximum age. Make the limits explicit and version them alongside the strategy.
On days three and four, connect order events to broker state. Treat submission, acknowledgement, partial fill, cancel request and confirmed cancellation as separate states.
A cancel request is not a cancellation. After a timeout, query by client order ID before retrying. Use idempotency keys where the API supports them; otherwise, reconcile open orders before resubmission to avoid duplicates.
On days five to seven, compare the agent's ledger with broker positions and open orders at startup, after reconnects and on a regular interval. Investigate any difference rather than silently adjusting the local ledger. Capture enough evidence to reconstruct the sequence.
- Store the decision, risk-check result and intended order before sending the request.
- Record broker responses, including rejects, timeouts, partial fills and rate limits.
- Reconcile positions and open orders after every connection interruption.
- Test that an alert reaches a person or on-call channel, not just a log file.
Use paper trading for the initial fault tests. A dedicated agentic paper trading environment can provide a lower-cost place to exercise order and alert flows, with access starting at $9.99 a month. Paper fills do not establish live execution quality, but the monitor should still detect stale data, duplicate requests and reconciliation errors.
Days 8 to 21: calibrate alerts and interventions
Set thresholds against the system's normal behaviour
Begin with conservative thresholds, then compare alerts with the event history. The ranges below are typical starting points for liquid intraday systems, not universal limits. Venue, instrument, polling method and strategy cadence all matter. Set strategy-specific limits before enabling orders.
| Signal | Typical starting range | Response |
|---|---|---|
| Agent heartbeat | Every 2 to 10 seconds; alert after 2 missed beats | Block new orders; check process and connectivity |
| Quote age | Pause entries after 2 to 5 seconds stale | Reject new signals until data is fresh |
| Order acknowledgement | Typical API response 100 to 800 ms; alert after 2 to 5 seconds | Query broker state before any retry |
| Order reject rate | Baseline often 0.1% to 1%; alert above 2% to 5% over 5 minutes | Stop the affected order path and inspect rejects |
| Position mismatch | Zero unexplained difference | Block new orders and reconcile immediately |
| Daily loss limit | Often 0.25% to 1% of allocated strategy equity | Cancel working orders and disable entries |
These figures are typical operating ranges, not audited results for any named company. A position mismatch should not inherit a tolerance from a generic table. Define whether rounding, contract multipliers or delayed fills can explain a difference, then halt on anything outside those rules.
Make alerts lead to a safe action
Classify events by what they require. A warning can be logged for review; a critical state should block new exposure.
Use separate controls for cancelling open orders and flattening positions. Automatic liquidation can create worse execution during a data outage or volatile market, so reserve it for conditions where the risk policy explicitly requires it.
Test the control path, not just the notification. During days eight to fourteen, inject a lost heartbeat, stale quote, broker timeout, reject burst and position mismatch.
Confirm that the monitor detects each fault within its expected window and that the action is recorded. During days fifteen to twenty-one, measure false alerts and missed alerts. If a threshold pages repeatedly without a required intervention, revise the rule or route it as a lower-severity event.
- Trigger one fault at a time and record detection time.
- Verify that new orders stop when the defined critical condition occurs.
- Confirm the broker state after a cancel or reconnect before restoring permission.
- Require an explicit operator acknowledgement to resume after a hard halt.
Days 22 to 30: rehearse the runbook and decide what stays enabled
Use the final nine days to run the monitor continuously in paper mode or with tightly capped live exposure, if the risk policy permits it. Keep size small enough that an alert test cannot create an unacceptable loss.
Do not switch directly from a quiet paper run to the full production limit. Market impact, partial fills, rate limits and broker outages differ in live conditions.
Write a runbook for each critical alert. It should state who receives it, what evidence to inspect, which orders can be cancelled, how positions are reconciled, and what conditions allow the agent to restart. Include a manual kill path that does not depend on the agent's own process or credentials. Test access to it during a simulated incident.
At day 30, review alert delivery, detection time, duplicate-order prevention, reconciliation differences and any unexplained state transitions. Set a go/no-go decision with limits: permitted instruments, maximum order size, maximum position, loss cap and trading hours.
Keep permissions narrow. For the next two weeks, continue the same checks and review every intervention. Week six is a sensible point to consider widening limits only if the event trail remains complete and no critical condition has gone unexplained.
The mistake most readers will still make after reading this is treating a green dashboard as evidence that the agent is safe.
Frequently Asked Questions
What should I monitor in an unattended trading agent?
Track agent health, market-data age, order acknowledgements, rejects, fills, open orders, positions and risk limits. Link each broker event to the agent's original decision so an operator can reconstruct what happened.
How often should a trading agent send a heartbeat?
For many systems, a heartbeat every 2 to 10 seconds is a practical starting range. Alert after missed beats based on the strategy's cadence and recovery needs, and block new orders if the monitor cannot establish the agent's state.
Should a trading agent automatically liquidate when monitoring fails?
Not by default. An automatic liquidation can worsen execution during a market-data or broker outage. Define separate policies for blocking new orders, cancelling working orders and flattening positions, and test each action before live use.
How long should I monitor an agent before increasing its limits?
Use the first 30 days to build and test the controls, then continue observing through at least week six before considering wider permissions. Extend the period if there are unexplained position differences, missed alerts or untested failure paths.