// Calendar-aware aggregation of bars to a coarser interval, and sparse-sampling helpers for realized measures. #pragma once #include "raid/data/bar_series.hpp" namespace raid::data { /// Aggregates bars into bins anchored at the regular session open (09:30 ET) of each session: /// bin k covers [open + k·Δ, open + (k+1)·Δ); the 16:00 closing print forms its own bin (FinData convention). Bins without bars are absent /// (no bar is manufactured). OHLC = first/max/min/last, volume = sum, trade_count = number of source bars. BarSeries aggregate(const BarSeries& bars, Interval target, const MarketCalendar& cal, SessionPolicy policy = SessionPolicy::regular); /// Subsampled price grid per session for realized measures: every `step` bars starting at `offset` (0 ≤ offset < step). /// Returns the close prices picked, grouped by session (offsets). Used for 5-minute subsampled RV on 1-minute bars. struct SampledPrices { std::vector p; std::vector session_offsets; std::vector session_dates; }; SampledPrices subsample(const BarSeries& bars, usize step, usize offset = 0); } // namespace raid::data