Lifecycle trace schema

Lifecycle trace schema

--lifecycle-json writes one JSON object (two-space indentation, one trailing newline, keys in the order given here) describing one run; see The order lifecycle trace for what it is for and a worked example. The schema is versioned by its first key; this is /1.

Within /1 the trace only adds: a record kind, or a summary key that is written only when it applies. GLE-458 added the timer kind and the summary’s timers object, GLE-459 the roll_account kind and the summary’s roll_replaced, roll_lost and roll_expired, GLE-479 the expiry kind and the summary’s contract_expiries, GLE-468 the cancel record’s basis, the summary’s calendar_cancels and the snapshot entry’s expires_at and expiry_basis, GLE-491 the roll_account record’s held_refused and the summary’s roll_held_refused, GLE-470 the run object’s lifetime and lifetime_source, GLE-532 I1 the submit record’s conviction, GLE-532 I13, on a run with a trade director, the director_decision kind, the submit record’s director_record and the summary’s director_decisions, and GLE-547 the submit record’s conviction_nonfinite, written only beside a conviction of null, for a conviction that is not a finite number (no earlier /1 file carried such a record: encoding it failed and the run ended), and GLE-1090 the six <level>_nonfinite keys of the submit record, the attached child and the snapshot entry, written only beside a level of null, for a price, stop price or trail amount that is not a finite number (no earlier /1 file carried such a record either), and GLE-1362 the cancel_request record’s source cancel_at and the summary’s scheduled_cancels; a run that writes none of them produces the file it wrote before, byte for byte. A consumer therefore reads the records whose kind it knows, skips the others, and ignores a summary key it does not know. The version moves to /2 when an existing key changes its meaning, its type or whether it is written, or when a kind is removed.

KeyValue
schema"algolang.lifecycle/1"
runrun_id; mode, plain for the bar loop or continuous for the served continuous loop; symbols, the run’s symbols (a continuous run names its composite’s canonical symbol); lifetime and lifetime_source, the run’s order-lifetime profile (v1 or v2) and how it was chosen (default or explicit), only when the profile is v2 or was defaulted, so a run under an explicit --lifetime v1 writes neither (GLE-470; Lifecycle turns); calendars, the run’s exchange-calendar provenance, only when the run asked for exchange calendars (see Engine side)
summarythe 25 counts in the summary, with roll_replaced, roll_lost, roll_expired and roll_held_refused among them on a run whose rolls re-placed, lost or expired an order or refused a held attempt, contract_expiries on a run that expired a dated futures contract, calendar_cancels on a run that ended an order at an exchange-calendar instant, scheduled_cancels on a run that cancelled an order at its Order.CancelAt and director_decisions on a run with a trade director, then timers on a run with timer records
recordsthe record stream, always an array
capital, equity, realized, fillsthe fill blotter as --fills-json writes it: the simulator’s capital, equity and realized P&L, and its fill reports (BrokerOrderID, Fill, Anchor, Series, BarTime); fills is null when the run made none, as the blotter writes

Records and their order

A record is a JSON object whose first four keys are its header: seq, 1 for the first record and +1 per record; kind, one of submit, cancel_request, fill, cancel, roll, snapshot, timer, roll_account, expiry, director_decision; bar, the index (0-based) of the loop bar current when the record was made, -1 before the first; and at, an instant in UTC as RFC 3339 with nanoseconds only when non-zero (2026-06-10T14:31:00Z), or "" for a zero instant.

The stream is the loop’s own order; seq is a record’s position and nothing is reordered. Within one loop bar the records come as the loop produces them: on a continuous run, the roll block when a boundary fires (the cancels of the venue’s terminations at the cut, the exchange-calendar instants’ then the GTC deadline’s at the roll’s date, then its roll record, cancel requests, legs, suppressed events and re-submissions, the rejected cancels of the orders it lost, and its roll_account record last); then the events delivered at the top of the bar (fill and cancel, in the simulator’s order: a cancel at an exchange-calendar instant, GLE-468, comes before the fills when the instant precedes the bar’s close and after them when the order’s own bar closes at it); then, once the strategy has seen the bar, its cancel requests (cancel_request, as it issued them) and its submissions (submit, as it returned them). Under lifetime v2 a dated futures contract due to expire before the bar writes, ahead of the bar’s own events and of any roll block, the cancels of the venue’s GTC deadline at the bar’s trade date when the GTC model is on, then its expiry record, then the cancels and the closing fill the expiry produced (the fill with an empty client_id and origin), each contract in expiration order; a contract expiring at a late roll writes the same inside the roll block, after the roll’s GTC cancels and before its roll record, and one expiring at the run’s end writes them after the last bar, before the snapshot and after the cancels of the exchange-calendar instants the run’s end reached (GLE-468). After the last bar: one snapshot, then the shutdown cancels. A roll’s records carry the index of the first incoming bar, because the loop marks the bar before the roll block runs; a roll a timer fires (below) carries the last observed bar’s.

Under lifetime v2 each step of a decision (its own reply, then each lifecycle turn’s) records its cancel requests, then its submissions, then its timer commands (timer, in command order). The timers due before a bar fire before that bar is marked, each a fire record followed by its decision’s records (a cancel at an exchange-calendar instant the timer reached first writes ahead of the fire), so they carry the index of the bar before; the timers due at the run’s end fire after the last bar, before the snapshot. On a continuous run (since I15 unit 2c, GLE-474) a roll whose cut is strictly before a timer’s instant fires ahead of the timer, so its roll block precedes the fire record and carries the last observed bar’s index, the loop not having marked the incoming bar; a roll the next bar fires carries that bar’s index. Both are the latest bar observation.

The at instant depends on the kind: a strategy submit or cancel_request carries the current bar’s close (the simulator’s clock at submission); a roll-sourced record carries the cut; a fill or cancel carries the event’s own timestamp (a roll’s suppressed cancel is stamped by the simulator at its own instant); the snapshot carries the last bar’s close. A timer record carries the decision’s instant for an arm, a disarm and a refusal at the arm, and the timer’s own instant for a fire and a timer_coarse refusal; the strategy records of a timer’s decision carry the timer’s instant.

submit — an order handed to the venue, or refused before it. Keys after the header: source, client_id, symbol, side, type, quantity, price, stop_price, trail_amount, tif, oco_group, venue_symbol, venue_price, venue_stop_price, venue_trail_amount, attached (only when the order carries attached children), legs (only on a combo order: symbol, side and ratio per leg, GLE-409), conviction (only when the order carries one, GLE-532: the number as encoding/json writes it, or null when it is not finite), conviction_nonfinite (only beside a null conviction: NaN, +Inf or -Inf, GLE-547), status, broker_id, reason. Each of the six levels (price, stop_price, trail_amount, venue_price, venue_stop_price, venue_trail_amount) is a number, or null when it is not finite, followed directly by its <level>_nonfinite key (price_nonfinite and so on: NaN, +Inf or -Inf), present only beside a null level (GLE-1090). A strategy level that is not finite is only ever on a record the engine refused, price_not_finite; a venue level can be one on an accepted record too, when translating a finite level into the venue’s frame overflowed. source is strategy (the strategy’s own orders), roll_leg (an engine roll leg) or roll_resubmit (a standalone resting order re-submitted onto the incoming contract at a roll; a stop the cut price was already through keeps its type and stop_price but shows venue_stop_price: 0, because it went to the venue as a market order, or as its limit at venue_price for a stop-limit). status is accepted (the venue booked it: broker_id is the simulator’s record id, reason is empty), denied (the venue refused it: broker_id is the record id the simulator still assigns, reason its text verbatim) or rejected (the engine refused it before the venue saw it: broker_id is "", reason the loop’s text). attached lists the order’s bracket children in order, each with client_id, side, type, quantity, price, stop_price, trail_amount, tif and the venue-frame venue_price, venue_stop_price, venue_trail_amount, each level with its <level>_nonfinite key as the record’s are. An accepted submit of any source is an attempt: one physical booking under its own broker id. A denied or rejected one is not. On a run with a trade director (GLE-532 I13) a strategy order refused before the venue by anything but the director’s own decision (the engine’s checks, the race guard, the admission limits, the decision log, the transport) is a submit with status rejected and a last key, director_record, the sequence of the decision-log record that refused it (The decision log); no rejection cancel follows it. The director’s refusal of an order whose conviction is not finite (director_invalid_conviction) carries conviction and conviction_nonfinite as every submit record does, before director_record.

director_decision — on a run with a trade director (GLE-532 I13), one of the director’s decisions on a candidate, its first or a recheck, without the snapshot it was decided against. Keys after the header: phase, origin, client_id, attempt, symbol, requested, reducing, accepted, reason_code, cause_code, rule, decision (the decision-log record’s sequence) and prior (the decision it rechecks, 0 for a first one). It is written when the log takes the decision, so it comes before the submit the decision allowed. A decision the director refused (accepted 0) has no submit record.

cancel_request — a cancellation asked of the venue. Keys: source (strategy; roll for a roll’s cancellation of a working order on the outgoing contract; or cancel_at for the cancellation an order’s Order.CancelAt asked for, recorded at the instant, status accepted, GLE-1362, Order.CancelAt), client_id, broker_id (the latest attempt under that client id; "" for an unknown id or a bracket child, which is not an attempt), status (accepted when the venue cancelled, else rejected), reason (the venue’s text when rejected). An accepted request settles the attempt it addressed at once: the simulator’s cancel is synchronous, and the cancel event itself drains with the next advance.

fill — a fill the venue produced. Keys: delivered, origin, client_id, parent_client_id, symbol, venue_symbol, side, quantity, price, venue_price, commission, combo_leg (only on a combo leg’s fill: the leg’s 1-based index, GLE-409), and sent_as and send_at (only on a held market-on-close order’s fill: MKT and the send time, send_at absent when no calendar placed one; GLE-1375). symbol and price are the strategy’s frame; venue_symbol and venue_price the venue’s; parent_client_id is set on a bracket child’s fill. A combo’s attempt settles on its last leg’s fill.

cancel — a cancel the venue produced. Keys: delivered, origin, client_id, reason, triggered_by (the sibling’s client id on an oco_triggered cancel) and, only on a cancel the venue made at an exchange-calendar instant under lifetime v2 (a tif_expired or gtc_expired cancel at a Day order’s session close or a GTC order’s quarter close; GLE-468, Calendar cancellation instants (lifetime v2)), basis, the DAY-cancel basis of the instant’s trade date, assumed in a backtest (the parent_cancelled and oco_triggered consequences carry none). The engine’s own rejection cancels, which follow a denied or rejected submit before the next bar, carry reason: rejected and an empty origin.

roll — a continuous roll boundary, recorded once per fired boundary after the loop has classified the working orders on the outgoing contract and read its net position, before that roll’s cancel requests, legs and re-submissions. Keys: from, to, position (the signed net position rolled), retranslated (client ids of the standalone orders re-submitted onto to), reestablished (bracket children re-attached to the open leg; on a flat roll, the working children the roll cancels instead), pinned (contract-addressed orders cancelled, and the strategy told). The three lists are always arrays and follow the roll plan’s classes (Roll execution at the cut).

roll_account — the account of a continuous roll once it has executed (GLE-459), recorded once per fired boundary after the roll’s last step, under either lifetime. Keys after the header: from, to, trade_date (the roll’s trade date, the synthetic incoming bar’s: the date on the exchange’s clock of the instant before its close), position (the signed net position rolled), expired and orders, both always arrays. expired lists, in the simulator’s order, the cancels of the venue-side terminations the roll ran before it read the book (under lifetime v2 with exchange calendars the calendar sweep at the cut, GLE-468; under --gtc-expiry ibkr-quarter the GTC quarter-end pass at the roll’s date; under lifetime v2 the contract expiry of the outgoing contract when the cut came after its expiration, Contract expiry (lifetime v2)), each with client_id, attempt, reason (the cancel’s label: tif_expired or gtc_expired at a calendar instant, gtc_expired at the roll’s date or contract_expired, and the oco_triggered and parent_cancelled consequences of an expiry) and triggered_by (the sibling’s client id on an oco_triggered cancel, else ""). orders lists every order the roll found working on the outgoing contract, in plan order, each with:

KeyValue
client_id, attemptthe order’s label and the attempt it worked under (0 under v1, and for an unstamped order)
classstandalone, child or pinned, the roll plan’s class
fatereattached (re-established on the open leg), resubmitted (re-submitted on the incoming contract, at the cut or after the synthetic bars), cancelled (the cancel delivered), dropped (the cancel hidden and nothing replaces it: a flat roll’s bracket child under v1) or lost (cancelled, and its replacement denied)
new_attemptthe attempt its replacement works under, or was to; 0 when it has none (v1, an unstamped or unlabelled order, a cancelled or dropped one)
broker_idthe broker id the replacement’s events carry as origin: the open leg’s for a re-established child, the re-submission’s own; "" when nothing replaces it, a lost order included
at_cutwhether a re-submission went at the cut (v2’s resting orders the cut price would not fill, outside an OCO group that went after the bars), else false
converted_tomarket or limit for a stop the cut price was through, re-sent as that type; else ""
reasona lost order’s denial, the simulator’s text verbatim; else ""

After orders, written only when the roll refused one, held_refused (GLE-491) lists the attempts the race guard held pinned to the outgoing contract that the roll refused hold_rolled (Order lifetime v2 across a roll), in hold order, each with client_id and attempt (the held order’s label and attempt) and symbol (the outgoing contract it was pinned to, from). A refused held attempt reached neither the venue nor the ledger, so no submit or cancel record accompanies the entry: the entry and the strategy’s Denied update are its whole record.

The roll record is the plan as classified before the cancels; the roll_account record is what became of each order. Four summary counts are kept from it (the summary).

expiry — a dated futures contract’s expiration at the venue under lifetime v2 (GLE-479, the final settlement since GLE-481; Contract expiry (lifetime v2)), recorded once per expired contract, before the cancels and the closing fill the expiry produced. at is the expiration instant (the events that follow carry their own stamp, the expiration or the simulation clock when it was later). Keys after the header, every one always written:

KeyValue
symbolthe contract, the venue symbol (ESH26)
seriesthe logical symbol of the continuous series holding the contract (fut:XCME:ES, or the :cont composite); "" for a plain contract
positionthe signed quantity the venue settled; 0 when the position was flat
settlethe price it settled at; 0 when flat
settle_sourcefinal_settlement (the exchange’s final settlement for the contract’s expiration date, read from the statistics stream before the run; GLE-481), settlement (the contract’s last served settlement, BarSession.settle, the statistics stream having carried no final settlement) or close (its last close, the feed having served no settlement either); "" when flat
cancelledthe client ids of the orders cancelled contract_expired, in the simulator’s order (their parent_cancelled children are not listed); always an array
latetrue when a continuous series’ contract expired before its roll or was still the active contract at the run’s end; false for a plain contract

snapshot — the working set at one instant; see the snapshot.

timer — one event of a strategy timer under lifetime v2 (Scheduled decision points). Keys after the header, every one always written: event, timer_id, timer_at, anchor, fired_at, code, reason, decision, decision_seq, turn.

eventRecorded forattimer_atanchorfired_atcode, reason
arman arm the engine admitted, a re-arm of an armed id (which replaces it) includedthe decision’s instantthe instant armedthe arm’s anchor; "" for an absolute timer""""
cancela disarm, whether or not a timer of its id was armedthe decision’s instantthe disarmed timer’s instant; "" when none was armedthe disarmed timer’s anchor""""
refusalan arm the engine refused: timer_invalid, timer_not_future, timer_after_end, calendar_incomplete, timer_limitthe decision’s instantthe instant asked for; "" when the arm had nonethe arm’s anchor""the code and the engine’s reason, as the strategy’s TimerRefused carries them
refusala timer refused at its instant: timer_coarsethe timer’s instantthe timer’s instantits anchor""as above
firea timer that fired: the engine sent its TimerFiredthe timer’s instantthe timer’s instantits anchorthe decision’s instant (the timer’s, on the stepped loops)""

decision, decision_seq and turn name the decision the event belongs to. An arm, a disarm or a refusal at the arm belongs to the decision whose reply carried the command: decision: bar and decision_seq: 0 for a bar’s (the record’s bar and at name it), or decision: timer and decision_seq the seq of the timer’s fire record; turn is the lifecycle turn whose reply carried it, 0 for the decision’s own reply. A fire opens its timer’s decision and a timer_coarse refusal refuses it: both carry decision: timer, their own seq and turn: 0. The other records of a timer’s decision, its cancel_requests and submits, name no decision; they follow its fire record, at its instant. A refused arm leaves an earlier arming of its id in place, so the armed timers can be kept from the records alone: an arm adds or replaces its id, and a cancel, a fire or a timer_coarse refusal removes it.

Frames and identity

Every submission and fill carries two frames. The strategy frame (symbol, price, stop_price, trail_amount; on a fill symbol, price) is what the strategy sent or received: the logical continuous symbol with adjusted levels, or the adjusted equity frame. The venue frame (venue_symbol, venue_price, venue_stop_price, venue_trail_amount; on a fill venue_symbol, venue_price) is what the simulator received or produced: the dated contract with raw levels, or the raw equity frame. On a series with no adjustment the two are equal. The venue frame is recorded as given. The continuous resolver translates only the levels an order type uses (a limit’s price, a stop’s trigger, both for a stop-limit), so a market or market-on-close order on the logical symbol reaches the contract with venue_price: 0 and venue_stop_price: 0.

Three identities run through the records:

  • client id (client_id): the strategy’s logical label. Translation onto a contract or a raw frame does not change it, a roll re-submission keeps it, and the strategy may re-use it once the previous order under it is terminal; the trace, like the simulator’s own cancel lookup, resolves a re-used client id to its newest attempt.
  • broker id (broker_id): the simulator’s attempt id, sim-N, one per physical booking. A re-translation at a roll is a new attempt under a new broker id; an activated bracket child has its own record id, which the trace first meets in the snapshot. A roll leg’s client id is roll/<symbol>/<cut in RFC 3339 UTC>/<close|open>.
  • origin (origin, on fill and cancel): the top-level broker id the event descends from — a standalone order’s own; the parent’s for a child’s fill or for an OCO or parent-cancelled cancel; after a roll, the open leg’s for the re-established children.

Rejections

Three different refusals are three different records:

  1. the engine refused an order before the venue saw it (on a continuous run, an order addressed to a symbol other than the logical symbol or the active contract; on every run, lifetime and wire, with or without a director, an order whose price, stop price or trail amount, or an attached order’s, is not finite, price_not_finite: price=NaN, GLE-1090): a submit with status: rejected, broker_id: "" and the loop’s reason; under lifetime v1 a cancel with reason rejected and an empty origin follows before the next bar, under v2 none does;
  2. the venue refused it (a symbol outside the instrument set, a non-positive quantity, …): a submit with status: denied, the record id the simulator assigned and its reason verbatim; the same rejected cancel follows;
  3. the venue refused a cancel request (an unknown or already terminal id): a cancel_request with status: rejected and the venue’s reason; the strategy hears a cancel reject and the book is untouched.

The snapshot and its join

The loops take the snapshot exactly once, after the last bar’s submissions and before the end-of-data cancellation, so it shows the residue the shutdown then sweeps: every entry it lists is followed by a shutdown cancel of that client id, and working_at_end counts its entries. It lists every order the simulator still holds as working, in submission order. Each entry carries the venue’s facts, broker_id, client_id and venue_symbol, then what the trace could join to them, by this rule:

  1. the broker id is an attempt (an accepted submit of any source): kind: top, with source, symbol, side, type, quantity, price, stop_price, trail_amount, tif, venue_price, venue_stop_price and venue_trail_amount copied from that submit record, each level with its <level>_nonfinite key as there (GLE-1090), parent_client_id empty and submitted_seq that record’s seq;
  2. else some attempt declared an attached child under the entry’s client id: the latest such attempt wins (after a roll, the open leg, whose attached list carries the child re-translated onto the incoming contract), giving kind: child, that attempt’s source, symbol and client_id (as parent_client_id), the child’s own levels and tif, and submitted_seq the attempt’s seq;
  3. else kind: unknown, every other string empty and every number zero.

An entry whose order the simulator holds an exchange-calendar instant for (under lifetime v2; GLE-468) ends with expires_at, that instant, and expiry_basis, its basis; an order without one writes neither key.

So an activated bracket child, which the simulator books under its own record id without an activation event, appears here joined to the bracket that declared it. After a roll a re-established child joins to the open leg: parent_client_id is the leg’s client id and symbol the incoming contract, the venue’s truth; the roll record’s reestablished list ties it back to the strategy’s bracket. A logical_parent_client_id is a candidate addition under a schema /2 if a consumer needs the strategy’s parent on the entry itself.

Labels

FieldValues
sidebuy, sell, else unspecified
typemarket, limit, stop, stop_limit, stop_trailing, moo, moc, loc, stop_touch, else order_type_<n>
tifday, gtc, ioc, fok; unspecified for none (a wire or an engine roll leg that carries no time in force); else tif_<n>
reason (on cancel)unspecified, oco_triggered, tif_expired, explicit, rejected, shutdown, parent_cancelled, gtc_expired (a GTC order cancelled at the venue’s quarter-end deadline under --gtc-expiry ibkr-quarter), corporate_action (a working order cancelled for a corporate action on its instrument under lifetime v2), contract_expired (a working order the venue ended at its dated futures contract’s expiration under lifetime v2), roll (an order a continuous roll cancelled under lifetime v2: delivered for an order pinned to the outgoing contract and a flat roll’s bracket child, hidden for an order the roll re-places), moc_send_missed (a live market-on-close order whose send time and session close passed while the engine was down, GLE-1375), else cancel_reason_<n>

Numbers are JSON’s defaults (50, not 50.0); booleans and zero numbers are always written; attached, a cancel’s basis, a snapshot entry’s expires_at and expiry_basis, a roll_account’s held_refused, and the summary’s roll_replaced, roll_lost, roll_expired, roll_held_refused, contract_expiries, calendar_cancels, scheduled_cancels, director_decisions and timers are the only omitted keys.

The summary

Every value is an integer. A strategy attempt is an accepted submit with source: strategy. An attempt’s own terminal is the first of: a fill with its broker id as origin, its client id and an empty parent_client_id (a child’s fill is the child’s, not the parent’s); a cancel with its broker id as origin and its client id, delivered or not; or an accepted cancel_request addressed to it. A terminal is sticky. An moc attempt that settles at submission (under lifetime v1) is left out of the two resting counts; under v2 an MOC waits for its send time (GLE-1375), in a backtest and on a live run’s IBKR venue, and is counted like any other attempt. The counts, in the file’s order:

KeyDefinition
barsloop bars observed (warm-up bars and a roll’s synthetic cut bars are not loop bars)
signalsdistinct bar values among strategy submit records (any status) and strategy cancel_request records
submittedstrategy submit records with status accepted or denied
accepted, denied, rejectedstrategy submit records, by status
attached_childrenchildren declared on accepted strategy submits
replacementsaccepted strategy submits whose client id appeared on an earlier strategy submit of any status
first_eligible_evaluationsstrategy attempts that reached their first eligible evaluation: a loop bar of the attempt’s venue symbol, observed while the attempt had no terminal, and closing strictly after the submission clock when the attempt was placed from another symbol’s bar (the simulator’s own rule). An order submitted on bar N of its symbol counts on bar N+1; one submitted on the last bar does not count; one cancelled from another symbol’s bar before its own symbol’s next bar does not count
unfilled_restingstrategy attempts, moc excluded, whose own terminal is not a fill: cancelled (delivered or suppressed, requested or venue-made) or still live
fills, suppressed_fillsfill records with delivered true, false
cancel_requestsstrategy cancel_request records; cancels_accepted and cancel_rejects split them by status
explicit_cancelsdelivered cancel records with reason explicit
unsolicited_cancelsdelivered cancel records with reason tif_expired, gtc_expired, oco_triggered, parent_cancelled, corporate_action, contract_expired, roll or moc_send_missed
shutdown_cancelsdelivered cancel records with reason shutdown
rejection_cancelsdelivered cancel records with reason rejected
suppressed_cancelscancel records with delivered: false
rollsroll records
roll_resubmits, roll_legssubmit records with source roll_resubmit, roll_leg
pinned_cancelledtotal length of pinned over roll records
roll_replacedentries of roll_account records whose fate is reattached or resubmitted; written only when not 0
roll_lostentries of roll_account records whose fate is lost; written only when not 0
roll_expiredexpired entries of roll_account records with reason gtc_expired (an oco_triggered consequence is not an expiry; a contract_expired entry is counted by contract_expiries, not here, and a Day order’s tif_expired entry at a calendar instant by calendar_cancels); written only when not 0
roll_held_refusedheld_refused entries of roll_account records: the attempts the race guard held pinned to an outgoing contract that the rolls refused hold_rolled (GLE-491). A guard denial is not a submit record, so denied and rejected do not count it; written only when not 0
contract_expiriesexpiry records, one per dated futures contract the venue expired under lifetime v2; written only when not 0
calendar_cancelscancel records carrying a basis, delivered or not: the Day and GTC orders the venue ended at an exchange-calendar instant under lifetime v2 (GLE-468; an oco_triggered or parent_cancelled consequence carries none and is not counted); written only when not 0
scheduled_cancelscancel_request records with source cancel_at: the orders the engine cancelled at their Order.CancelAt (GLE-1362). cancel_requests, cancels_accepted and signals leave them out; their cancels are among explicit_cancels; written only when not 0
director_decisionsdirector_decision records (GLE-532 I13); written only when not 0
working_at_endentries on the last snapshot; 0 without one
timersonly on a run with timer records, else not written: an object of four counts, arms, cancels, fires and refusals, the timer records by event (timer_coarse refusals included). Timer records change no other count; the strategy records of a timer’s decision count as any other, under the index of the bar before the timer

A delivered cancel with reason unspecified or an unlabelled code falls in none of the four cancel classes. The eligibility count and each attempt’s terminal are kept as the loop runs, not derived from the records afterwards: a bar observation is not a record, and the “no terminal yet” test at each bar needs the terminal set as it stood then.

Coverage

The trace covers backtest strategy runs, plain and continuous (the one bar loop, with a continuous series’ bars through its frame), and nothing else: live mode and the TRADES schema refuse the flag before any spawn. Within a run it does not record:

  • warm-up bars (the loops do not observe them: no records, not counted in bars) or a roll’s two synthetic cut bars (their events are recorded under the first incoming bar’s index);
  • a bracket child’s activation. The simulator emits no such event; a child shows through its own events (origin the parent’s, or after a roll the open leg’s, broker id; parent_client_id on its fill) and through the snapshot, under its own record id, joined to its declaration;
  • the rewriting of resting orders at a split on a v1 run. The simulator rewrites them silently; a rewritten order still working at the end is listed in the snapshot under its broker id, joined to its pre-split declaration (the quantity and levels as submitted, not as rewritten). Under lifetime v2 the orders are cancelled instead, and each cancel is recorded with reason corporate_action (Corporate actions and working orders (lifetime v2));
  • corporate-action and roll notices, account-state pushes, and the strategy’s own view of its orders.

The trace reads the venue’s answers and returns them unchanged; it drops, re-orders and decides nothing, and the loops hold no trace at all without the flag.

Exit behavior

algo run exits 0 on success; 1 on any run failure, with a single algo: <reason> line on stderr; 2 on usage errors. A multi-run config fails fast, the first failing run aborting the rest, unless the set keeps going (report.keep-going, on by default when it exports): it then exits 1 only when every run failed (When a run of a set fails). A strategy process exits 0 after a clean shutdown, non-zero when algolang.Run returns an error (init failure, protocol violation, an OnBar error). At end of run the engine cancels all remaining working orders (your OnCancel hears Shutdown as the reason) before OnShutdown runs.

Everything a strategy prints to stderr passes through to your terminal, prefixed [<binary>]; stdout belongs to the wire protocol – never print to stdout in a strategy, use ctx.Log or stderr.

Stopping a run

Ctrl-C (SIGINT) or SIGTERM stops the run in progress and the set with it, report.keep-going or not (GLE-494). The engine says so on stderr, and a strategy waiting to be answered, or one that has stopped answering, is let go within 2 s:

$ algo run --strategy ./bin/smacross --symbols fut:XCME:ES --bar-interval 1d
^Calgo: interrupt signal received: stopping the run (a second signal kills the process)
algo: engine: smacross: strategy I/O interrupted while reading: interrupt signal received

The run fails like any failed run: exit status 1 and a single algo: line; a set leaves no index.json, even when the signal came after its last run had started. The engine cannot interrupt a data fetch in progress, so a second Ctrl-C kills the process at once, and a run that has not stopped 10 s after the first signal is ended by the engine itself, with the signal, so a single SIGTERM from a supervisor still ends it. The strategy and the adapter share your terminal and usually get the same Ctrl-C: when one of them ends the run first, its error is printed with the cause after it (...: EOF; the run was interrupted (interrupt signal received)). A SIGINT the process was started with ignored, as a background job of a script is, stays ignored.

A strategy has 30 s from its start to write its hello line; one that writes nothing fails the run (engine: <strategy> wrote no hello line within 30s, the strategy handshake deadline (a strategy writes its hello line as it starts)), and its process is killed. Every SDK writes the line as the strategy starts.

A strategy that stops answering holds the run until you stop it, unless the run sets the strategy stall timeout (GLE-496). It is off by default, since a slow strategy on a big bar is not a stall:

algo run --strategy ./bin/smacross --symbols fut:XCME:ES --bar-interval 1d \
  --strategy-stall-timeout 2m

or, in a run config, under any level’s data:

{"data": {"adapter": "marketfeed-adapter", "strategy-stall-timeout": "2m"}}

The timeout bounds each wait on the strategy: for its next reply frame, or for it to take what the engine writes. Every frame the strategy sends ends a wait, so a reply of several frames may take longer than the timeout as a whole; a log line is not a reply. A run that stalls fails with engine: <strategy>: strategy I/O interrupted while reading: the strategy sent no reply within 2m0s (strategy-stall-timeout) (or, for a strategy that stopped reading, while writing: the strategy did not take what the engine wrote within 2m0s). A stall fails that run alone, so a set that keeps going goes on to its next run. Set the timeout well above the longest a warm-up chunk of up to 50,000 bars can take: under pb the strategy answers a warm-up batch with one reply, and under stdio-csv-v2 the engine writes a warm-up block as one write, which the strategy takes as it works through the block. A negative value is refused.