Skip to main content

Module replace_orders

Module replace_orders 

Source

Re-exportsΒ§

pub use super::bulk_orders::BulkOrderResult;

StructsΒ§

BulkReplaceOrderRequest
BulkReplaceOrderResponse
ValidatedReplace πŸ”’
A replace request that has passed signature / authorization / parsing validation and is ready to be turned into a (CancelOrder, CreateOrder) pair by the bulk-replace orchestrator. Splitting validation from dispatch lets orchestrate_bulk_replace be unit-tested with a mocked engine sender.

ConstantsΒ§

BULK_REPLACE_PHASE_DEADLINE πŸ”’
Per-phase deadline for the bulk-replace handler. Unlike ENGINE_RESPONSE_TIMEOUT (which is the per-message budget on the singular endpoints), this is the budget for all legs in a phase combined. Keeps worst-case bulk latency bounded even if a single leg’s response is hung. Phase 1 and Phase 2 each get their own deadline of this size, so a 50-leg bulk is bounded by roughly 2 Γ— this duration end-to-end.

FunctionsΒ§

build_cancel_message πŸ”’
Build an OrderAction::CancelOrder message targeting this replace’s pre-existing order. symbol is intentionally empty β€” the engine resolves it from order_id in its per-wallet order index (see how cancel_order() does it in this file).
build_create_message πŸ”’
bulk_replace_order
Replace multiple orders using cancel-all-then-create-all ordering.
dispatch_to_engine πŸ”’
Send an OrderActionMessage through the engine queue. Returns the response receiver. Returns Err(()) if the engine queue is closed.
merge_leg_result πŸ”’
orchestrate_bulk_replace πŸ”’
Drive the cancel-all-then-create-all dispatch against a provided engine request sender.
replace_order
Atomically cancel an existing order and place a new one.
validate_replace_request πŸ”’
Run signature verification, agent authorization, symbol parsing, trading-allowed checks, and price/size parsing + precision checks. Returns a ValidatedReplace on success, or a pre-populated BulkOrderResult carrying the rejection reason on any failure.