Skip to main content

parse_bar

Function parse_bar 

Source
pub fn parse_bar(
    ohlcv: &Ohlcv,
    bar_type: BarType,
    instrument: &InstrumentAny,
) -> Result<Bar>
Expand description

Converts a historical OHLCV period into a bar of the requested type, taking both ts_event and ts_init from time_period_end.

Rounds volume to the instrument’s size precision when the adjustment is at most both 1e-15 times the reported volume and 1e-6 times one unit at that precision.

§Errors

Returns an error if a price is finer than the instrument precision, volume needs rounding beyond the noise tolerance, the prices are inconsistent, or a timestamp is invalid.