pub async fn executions<U, F, Fut>(
ud: &U,
rx: &mut Receiver<Envelope>,
source: &str,
id: &InstrumentId,
price: Price,
fill: F,
)Expand description
Own executions: the history works, and a fill arrives as an Execution event and in the history.
Steps and checks:
executions(range)over a very wide range succeeds on an empty account.subscribe_executions.- Place a buy limit order, two lots, at
price(rate-limit refusals are waited out and retried under a fresh cid), then callfill(cid). - An [
brokapi_core::Event::Execution] arrives. Its source issource, itssubis the executions subscription, its cid is ours, price and quantity are positive, the trade id is not empty and the instrument isid. executions(range)now lists at least one trade, each with a positive price, positive quantity and a trade id.
fill(cid) makes the mock execute the order. Each mock has its own way, so the adapter provides it.
It may wait until the stream is open. It runs once. price must be far from the market and accepted
by the mock, and the fill itself is the mock’s business. The command gate must be open, so call
reconcile first, and wait for the adapter’s event socket if it connects in the background.
§Panics
With [conformance:executions] <reason> when a call fails, no execution arrives in time, or a check
fails.
§Examples
brokapi_conformance::reconcile(&ud).await;
brokapi_conformance::executions(&ud, &mut rx, "bcs-ud", &sber, Price::from(100), |cid| {
// The BCS mock executes an order when told: cid, quantity, price.
let _ = server.fill(&cid.hyphenated().to_string(), brokapi_core::Qty::from(20), brokapi_core::Price::from(100));
async {}
})
.await;