pub fn base_to_htf_index(
base_candles: &[Candle],
htf_candles: &[Candle],
) -> Vec<Option<usize>>Expand description
Map each base-timeframe index to the most recently completed HTF bar index.
A “completed” HTF bar is one whose timestamp (the last constituent bar’s
timestamp) is less than or equal to the current base bar’s timestamp.
Using <= rather than < ensures that on the final bar of an HTF period
(e.g. a Friday close for a weekly bar), the engine can immediately see the
now-finalized HTF candle. Using < would introduce an artificial one-bar
delay: on Friday, htf.timestamp == base.timestamp, so < fails and the
engine falls back to the prior week’s data even though the weekly bar is
already complete.
htf_candles must have been produced by resample with the same
utc_offset_secs used for the base series so that bucket boundaries are
consistent.
Returns None for bars where no HTF bar has completed yet (e.g. during
the first HTF period).