Skip to main content

stop_without_answer_keeps_its_cid

Function stop_without_answer_keeps_its_cid 

Source
pub async fn stop_without_answer_keeps_its_cid<U: StopOrderExecutor + ?Sized>(
    ud: &U,
    id: &InstrumentId,
    stop_price: Price,
    lose: impl Fn(bool),
)
Expand description

A stop order the broker took, whose answer was lost, comes back in the list with its cid.

The failure that costs money: the stop order is at the broker and the bot was told nothing. lose turns the fault of the imitation on (true: the broker takes a stop order, then the answer is lost) and off (false). The connector must not send again and must not lose the link between the stop order and the cid. Steps:

  1. With the fault on, place_stop is [Error::Unknown].
  2. The same cid again is Rejected(duplicate_place): a stop order is never sent twice.
  3. active_stop_orders shows exactly one stop order, and its cid is the one that was sent. Whether the broker returns the number or the connector finds the stop order by what was asked for, the bot sees the same.
  4. cancel_stop by that cid removes it.

§Panics

With [conformance:stop_without_answer_keeps_its_cid] <reason>.

§Examples

brokapi_conformance::reconcile(&ud).await;
brokapi_conformance::stop_without_answer_keeps_its_cid(&ud, &sber, Price::from(200), |lose| {
    opts.stop_answer_lost.store(lose, Ordering::SeqCst)
})
.await;