Skip to main content

Module execution

Module execution 

Source
Expand description

Live execution client for the Betfair adapter.

§Submission gate

The client halts new-order submissions whenever the execution stream is unavailable or recovering. submit_order and submit_order_list emit OrderDenied with STREAM_RECONCILING, while cancel and modify commands remain available. Transport availability alone does not reopen the gate: an active replacement socket remains halted until the order subscription is current and the matching recovery task dispatches mass status.

§Reconnect recovery

A transport loss or server connectionClosed status advances the reconciliation generation immediately. A replacement Connection raises pending_resync; a complete SUB_IMAGE or RESUB_DELTA queues the current generation once. Subsequent OCMs remain buffered until process_pending_resync runs on the engine thread. Connectivity polling and command or report entry points invoke it to synchronize OCM state from the cache and drain the buffer.

The recovery task attempts to refresh the session, requests account state on a best-effort basis, and builds a mass status from list_current_orders. Recovery uses match-time ordering and bounded retries to include fills that completed and rolled off the unmatched book during the gap.

Mass-status dispatch, fill-deduplication commit, and gate reopening share one generation check; the task does not wait for a separate cache-application acknowledgement. A newer transport loss or replacement connection cancels older work. Failed authentication, exhausted recovery, or a failed report dispatch leaves the gate closed until a later reconnect succeeds or the client disconnects. A keep-alive failure other than explicit LoginFailed continues recovery with the retained session.

§Modify reconciliation

An ambiguous replace or quantity reduction remains pending until OCM or listCurrentOrders confirms it; only a fully paginated response can prove the original order non-actionable. Reconciliation emits the resulting OrderUpdated directly and withholds active reports that would reapply or contradict that update. A terminal replacement report follows its OrderUpdated through the normal report path and enters terminal retention. A terminal reduction needs no preceding update; its confirmed quantity overrides Betfair’s original stake in that report and later reports.

Structs§

BetfairExecutionClient
Betfair live execution client.