Skip to main content

market_data_streams

Function market_data_streams 

Source
pub async fn market_data_streams<M: MarketDataSource + ?Sized>(
    md: &M,
    rx: &mut Receiver<Envelope>,
    source: &str,
    id: &InstrumentId,
    candle_tf: Timeframe,
)
Expand description

Market trades, quotes and candles as streams, each for the right instrument and tagged with our source and subscription id.

For each of the three kinds the scenario subscribes, then waits (up to EVENT_TIMEOUT) for an event of that kind on that subscription, and checks:

  • trades: source, instrument, positive price and quantity;
  • quotes: source, instrument, at least a bid or an ask, and not crossed (bid not above ask);
  • candles: source, instrument, the asked candle_tf, low not above high.

Trades use [brokapi_core::SubscribeOpts::lossless] (64), quotes and candles use [brokapi_core::SubscribeOpts::conflate]. The subscriptions are left open. The mock must push a trade, a quote and a candle after each subscribe. rx must be the receiver of the connector under test.

§Panics

With [conformance:market_data_streams] <reason> when a subscribe fails, an event does not arrive in time, or a check fails.

§Examples

brokapi_conformance::market_data_streams(&md, &mut rx, "bcs-md", &sber, Timeframe::M1).await;