Write a trading-system data-availability contract
Define what each feature could know at decision time before running the backtest.
Design idempotency, partial fills, stale signals and restart reconciliation before live execution.
Educational research design and invented arithmetic examples. No strategy returns, broker execution or production certification are supplied.
An intent to buy is not an accepted order, and an accepted order is not necessarily a fill. Model pending submission, acknowledgement, partial fill, filled, cancel requested, cancelled and rejected states as appropriate to the broker API. Preserve broker order identifiers alongside internal intent identifiers.
A timeout creates uncertainty: the request may have failed before reaching the broker or succeeded before the acknowledgement was lost. Blindly submitting another market order can double exposure. Query and reconcile the authoritative account state under a documented policy.
Use a stable idempotency key for one instruction where the API supports it. Otherwise maintain a durable instruction-to-order record and a conservative uncertain-state process. A fresh process identifier should not turn the same stale instruction into a new trade.
Test duplicates before and after acknowledgement, network interruption during submission, and restarts with outstanding orders. Those fixtures exercise software behaviour; they are not simulated trading profits or a production-readiness certificate.
Track requested, filled, remaining and cancelled quantity. Average fill price is meaningful only with the matching quantity and fee allocation. An exit for the original requested amount can over-close or reverse a partially filled position if the system ignores the actual state.
Decide how the policy treats an entry that remains partly open beyond its expiry. Save cancel requests and later fills that arrive during cancellation. The broker's current API documentation, not a generic state diagram, governs the actual legal sequence.
Reload the last durable state, inspect broker positions and open orders, and reconcile them before permitting new instructions. Identify manual positions separately. Do not infer a flat account from an empty in-memory cache or a missing local file.
For production, durable state, scheduling and failure reporting must belong to managed cloud services and continue with personal computers off. Local notebooks and this site's browser worksheets are research tools, not production publishers, monitors or fallback execution paths.
Write down who can stop new entries, how open orders are reviewed, how existing exposure is handled and what evidence is needed before resuming. A kill switch that stops the process may leave orders resting at the broker. A control that cancels orders may leave positions open.
Keep an incident timeline and compare intended orders, actual broker fills and accounting after recovery. QuantConnect's reconciliation documentation is a platform example of comparing live and simulated behaviour; it does not certify an unrelated implementation.
A successful local restart fixture exercises the code paths you simulated. Production requires a real managed-cloud execution, durable state and authoritative account or artifact readback under its actual identity. Do not call code presence, a research LIVE label or an inventory of endpoints proof that the intended subscriber route is deployed and certified.
Trading-system expectancy after costs
Define what each feature could know at decision time before running the backtest.
Keep selection decisions, rejected candidates and untouched evaluation periods auditable.
The sample engine fills whole one-unit market intentions at next opens and ends flat with forced finalisation disabled. It supplies no network timeout, broker acknowledgement, partial fill or actual cancellation race. Those source questions remain in the original recovery guide. A simulation's empty end state cannot certify that a real account is flat after restart. Production ownership, durable cloud state, pending orders and independent route readback require actual operational evidence. The teaching packet adds traceable mechanics, not a local production fallback or a replacement for authoritative account reconciliation.