Skip to main content

instrument_lookup

Function instrument_lookup 

Source
pub async fn instrument_lookup<M: InstrumentSource + ?Sized>(
    md: &M,
    query: InstrumentQuery,
    id: &InstrumentId,
)
Expand description

Instrument directory: a search finds the instrument, and its trading parameters are usable for order sizing.

Checks:

  • md.find(query) succeeds and the result contains an instrument with the same [brokapi_core::InstrumentKey] as id;
  • md.trading_params(id) succeeds with lot_size > 0 and price_step > 0. Both are used to round order quantities and prices, so zero would make every order invalid.

query must be a search that finds id. The mock must list that instrument and serve its parameters.

§Panics

With [conformance:instrument_lookup] <reason> when a call fails, the instrument is not found, or a parameter is not positive.

§Examples

let query = InstrumentQuery::ByTicker { ticker: "SBER".into(), exchange: None };
brokapi_conformance::instrument_lookup(&md, query, &sber).await;