Skip to main content

Module reconciliation

Module reconciliation 

Source
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:

Invariants maintained across all paths:

  1. When enabled, synthetic adjustment aligns position quantity with the venue within instrument precision.
  2. When enabled, synthetic adjustment aligns average price with the venue within tolerance (default 0.01%).
  3. All generated fills preserve correct unrealized PnL.
  4. Synthetic trade_id and venue_order_id values are deterministic functions of the logical event, so restart replays dedupe.

See docs/concepts/reconciliation.md for the operator-facing description.

Structs§

ReconciliationResult
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 TradeId for an inferred reconciliation fill.
create_position_reconciliation_venue_order_id
The account_id scopes the ID to the venue account, preventing cross-account collisions where the engine would otherwise fall back to ClientOrderId::from(venue_order_id) and conflate orders from different accounts. The ts_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 OrderRejected event for reconciliation.
create_reconciliation_triggered
Creates an OrderTriggered event 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 OrderFilled event from a FillReport.
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.