Skip to main content

Module settlement_ops

Module settlement_ops 

Source
Expand description

Settlement persistence operations.

Free functions that take &mut PgConnection so they can be called from any context (DatabaseHandler trait impl, transaction closures, tests). Previously lived as private methods on DieselEventHandler.

Functionsยง

claim_settlement_in_tx
Idempotent settlement claim: inserts expiration + payout + ledger event in one transaction. Panics on invariant violations (data corruption). Returns whether this was a new claim or a duplicate replay.
extract_expiry_ts
Parse a symbol string and extract its expiry timestamp.
insert_settlement_ledger_event_in_tx ๐Ÿ”’
insert_settlement_payout_in_tx ๐Ÿ”’
load_settlement_payout_in_tx ๐Ÿ”’
lock_and_validate_existing_settlement_claim_in_tx ๐Ÿ”’
mark_settlement_payout_applied_in_tx ๐Ÿ”’
observe_applied_settlement_in_tx
Read-only validation of an already-applied settlement (standby replay path). Panics on any inconsistency between the replay and the persisted state.
query_total_fill_volume
Total fill count and notional volume across all fills.
settlement_ledger_delta_for_margin_mode
Compute the ledger cash delta for a settlement based on margin mode. Standard mode uses settlement_value; portfolio mode uses net_pnl.
validate_existing_settlement_claim_readonly ๐Ÿ”’
validate_existing_settlement_ledger_in_tx ๐Ÿ”’
validate_existing_settlement_ledger_readonly ๐Ÿ”’
validate_existing_settlement_payout_facts ๐Ÿ”’
validate_settlement_economics_tuple
Validate settlement economics (entry price, cost basis, net PnL) and return as a tuple.
validate_settlement_ledger_deltas ๐Ÿ”’