Skip to main content

load_candles

Function load_candles 

Source
pub async fn load_candles<S: MarketDataSource + ?Sized>(
    src: &S,
    id: &InstrumentId,
    tf: Timeframe,
    range: TimeRange,
    opts: HistoryOpts,
) -> Result<Vec<Candle>, HistoryError>
Expand description

Reads the whole range into memory: CandlePages until the end.

Suits a few thousand bars. For a year of minute bars of many instruments write page by page instead, so memory does not grow.

§Errors

As CandlePages::next_page. Bars read before the error are lost with it: use CandlePages when you need them.

§Examples

let bars = load_candles(md, sber, Timeframe::D1, range, HistoryOpts::default()).await?;
assert!(bars.windows(2).all(|w| w[0].open_ts < w[1].open_ts));