Expand description
Execution state reconciliation.
Pure functions for bringing the engine’s local order, fill, and position state into line with what the venue reports. Called at startup (mass status) and continuously at runtime (open-order and position checks).
Public entry points:
process_mass_status_for_reconciliation- partial-window fill reconstructionprocess_mass_status_for_reconciliation_without_synthetic_reports- reconstruction that preserves the input report set when adjustment would require synthetic reportsgenerate_reconciliation_order_events- venue-temporal event sequence for a reportreconcile_order_report- core order-state reconciliationreconcile_fill_report- apply a venue fill to a cached order, with dedupgenerate_external_order_status_events- synthesize events for an external ordercheck_position_reconciliation- final qty and avg-px tolerance check
Invariants maintained across all paths:
- When enabled, synthetic adjustment aligns position quantity with the venue within instrument precision.
- When enabled, synthetic adjustment aligns average price with the venue within tolerance (default 0.01%).
- All generated fills preserve correct unrealized PnL.
- Synthetic
trade_idandvenue_order_idvalues are deterministic functions of the logical event, so restart replays dedupe.
See docs/concepts/reconciliation.md for the operator-facing description.
Structs§
- Reconciliation
Result - Result of processing fill reports for reconciliation.
Functions§
- calculate_
reconciliation_ price - Calculate the price needed for a reconciliation order to achieve target position.
- check_
position_ reconciliation - Check if a cached position matches the venue position report within tolerance.
- create_
incremental_ inferred_ fill - Creates an inferred fill for the quantity difference between order and report.
- create_
inferred_ fill_ for_ qty - Creates an inferred fill with a specific quantity.
- create_
inferred_ reconciliation_ trade_ id - Create a deterministic
TradeIdfor an inferred reconciliation fill. - create_
position_ reconciliation_ venue_ order_ id - The
account_idscopes the ID to the venue account, preventing cross-account collisions where the engine would otherwise fall back toClientOrderId::from(venue_order_id)and conflate orders from different accounts. Thets_last(venue-provided) ensures that successive reconciliation incidents with the same shape get distinct IDs, while the same logical event replayed after restart still hashes the same (venue re-reports identical ts). - create_
reconciliation_ rejected - Creates an
OrderRejectedevent for reconciliation. - create_
reconciliation_ triggered - Creates an
OrderTriggeredevent for reconciliation. - generate_
external_ order_ status_ events - Generates the appropriate order events for an external order and order status report.
- generate_
external_ order_ status_ events_ with_ commission - Generates external-order status events with a precomputed inferred-fill commission.
- generate_
reconciliation_ order_ events - Generates reconciliation events for a live order status report.
- generate_
reconciliation_ order_ pre_ fill_ events - Generates acceptance, amendment, and triggering events for a report paired with real fills.
- generate_
reconciliation_ order_ snapshot_ events - Generates reconciliation events for an authoritative venue snapshot.
- generate_
reconciliation_ order_ snapshot_ events_ with_ commission - Generates reconciliation events for an authoritative venue snapshot with an inferred-fill commission supplied by the responsible execution client.
- incremental_
inferred_ fill_ price_ and_ liquidity - Resolves the price and liquidity side that an incremental inferred fill will carry.
- inferred_
fill_ price_ and_ liquidity - Resolves the price and liquidity side that an inferred fill will carry.
- process_
mass_ status_ for_ reconciliation - Process fill reports from a mass status for position reconciliation.
- process_
mass_ status_ for_ reconciliation_ without_ synthetic_ reports - Process fill reports without generating synthetic order or fill reports.
- reconcile_
fill_ report - Creates an
OrderFilledevent from aFillReport. - reconcile_
order_ report - Reconciles an order with a venue status report, generating appropriate events.
- reconcile_
order_ report_ with_ commission - Reconciles an order with a venue status report using a precomputed inferred-fill commission.
- should_
reconciliation_ update - Checks if the order should be updated based on quantity, price, or trigger price differences from the venue report.