SPB Git

spb/wp40_uqo

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

Theme