pub async fn order_state_events<U: OrderExecutor + ?Sized>(
ud: &U,
rx: &mut Receiver<Envelope>,
source: &str,
id: &InstrumentId,
price: Price,
)Expand description
The order stream: placing an order gives an event for our cid, cancelling it gives a Cancelled event.
Steps and checks:
subscribe_order_state.- Place a buy limit order, one lot, at
price, under a fresh cid. A local rate-limit refusal is waited out and retried under a fresh cid (a cid is never sent twice). - An [
brokapi_core::Event::Order] for our cid arrives. Its source issource, itssubis the subscription from step 1, and its state is notRejected. - Cancel the order. An order event with state
Cancelledfor the same cid arrives on the same subscription.
Each wait is limited to EVENT_TIMEOUT. price must be far from the market and accepted by the
mock. The command gate must be open, so call reconcile first. The mock must push an order event
when an order is placed and when it is cancelled. If the adapter opens its order event socket in the
background, wait until it is connected before running this scenario, otherwise the first event can
be missed.
§Panics
With [conformance:order_state_events] <reason> when a call fails, an event does not arrive, or a
check fails.
§Examples
brokapi_conformance::reconcile(&ud).await;
brokapi_conformance::order_state_events(&ud, &mut rx, "bcs-ud", &sber, Price::from(100)).await;