pub async fn stop_order_far_from_market<U: StopOrderExecutor + ?Sized>(
ud: &U,
id: &InstrumentId,
stop_price: Price,
)Expand description
Stop orders, the common path: place, list, cancel by cid, then a stop-limit cancelled by broker id.
Steps and checks:
- A stop-loss SELL, one lot, at
stop_price. The ack carries the same cid and a non-empty broker id. The order is then inactive_stop_orders()with the same cid, kindStopLoss, sideSell, the stop price and quantity we sent, no limit price, and stateActive.cancel_stopby [brokapi_core::StopOrderRef::Cid] succeeds and the order leaves the list. - A stop-limit SELL with limit price
stop_price * 0.99. It appears in the list with kindStopLimitand a limit price. It is cancelled by [brokapi_core::StopOrderRef::Broker] and leaves the list. - A stop-limit without a limit price is refused with [
brokapi_core::Error::Rejected] before anything is sent, and the active list is empty afterwards (so the mock must start with no stop orders).
stop_price must be far BELOW the market: the orders are SELL stops, they must not trigger. The
command gate must be open, so call reconcile first. There is no rate-limit retry in this scenario.
The mock must accept a stop order, list it while it waits, and cancel it.
§Panics
With [conformance:stop_order_far_from_market] <reason> when any check above fails.
§Examples
brokapi_conformance::reconcile(&ud).await;
assert!(ud.caps().supports_stop_orders);
brokapi_conformance::stop_order_far_from_market(&ud, &sber, Price::from(200)).await;