Skip to main content

place_and_cancel

Function place_and_cancel 

Source
pub async fn place_and_cancel<U: OrderExecutor + ?Sized>(
    ud: &U,
    id: &InstrumentId,
    price: Price,
)
Expand description

Places a far-from-market limit order, reads its state by cid, cancels it.

Steps and checks:

  1. place a buy limit order, one lot, at price, with a fresh cid. The ack must carry the same cid and a non-empty broker order id.
  2. order_state(cid) must return a snapshot for that cid that is not Rejected.
  3. cancel(cid) must succeed.

price must be far below the market so the order rests and does not fill, and must be a price the mock accepts (not REJECT_PRICE). There is no retry: a local rate-limit refusal is a failure here. The command gate must be open, so call reconcile first.

The mock must acknowledge a limit order, report its state, and cancel it.

§Panics

With [conformance:place_and_cancel] <reason> when place, order_state or cancel fails, or the ack or snapshot is wrong. A NotReconciled error here means reconcile was not run first.

§Examples

brokapi_conformance::reconcile(&ud).await;
brokapi_conformance::place_and_cancel(&ud, &sber, Price::from(1)).await;