统一日线事件上下文并接入完成分钟事件回测

This commit is contained in:
boris
2026-09-09 23:29:54 +08:00
parent 5dc5ef9df5
commit bbbd9cf3e0
8 changed files with 1007 additions and 48 deletions
+15
View File
@@ -491,6 +491,7 @@ pub struct DataSetSnapshotComponents {
pub benchmarks: Vec<BenchmarkSnapshot>,
pub corporate_actions: Vec<CorporateAction>,
pub execution_quotes: Vec<IntradayExecutionQuote>,
pub completed_minute_bars: Vec<crate::session_events::MinuteBar>,
}
#[derive(Debug, Clone, Serialize)]
@@ -1418,6 +1419,7 @@ pub struct DataSet {
eligible_universe_by_date: Arc<OnceLock<BTreeMap<NaiveDate, Vec<EligibleUniverseSnapshot>>>>,
benchmark_code: String,
futures_params_by_symbol: Arc<HashMap<String, Vec<FuturesTradingParameter>>>,
completed_minute_bars: Arc<BTreeMap<(NaiveDate,String),Vec<crate::session_events::MinuteBar>>>,
}
struct DailySymbolRows<'a, T> {
@@ -1954,6 +1956,7 @@ impl DataSet {
eligible_universe_by_date: Arc::new(OnceLock::new()),
benchmark_code,
futures_params_by_symbol: Arc::new(futures_params_by_symbol),
completed_minute_bars: Arc::new(BTreeMap::new()),
})
}
@@ -2627,9 +2630,21 @@ impl DataSet {
benchmarks,
corporate_actions,
execution_quotes,
completed_minute_bars:self.completed_minute_bars.values().flatten().cloned().collect(),
}
}
pub fn with_completed_minute_bars(mut self,bars:Vec<crate::session_events::MinuteBar>)->Result<Self,String> {
self.completed_minute_bars=crate::session_events::bar_store(bars)?;Ok(self)
}
pub fn with_shared_completed_minute_bars(mut self,bars:crate::session_events::BarStore)->Self {self.completed_minute_bars=bars;self}
pub fn completed_minute_bar_count(&self)->usize {self.completed_minute_bars.values().map(Vec::len).sum()}
pub fn completed_minute_bars_on(&self,date:NaiveDate,symbol:&str)->&[crate::session_events::MinuteBar] {
self.completed_minute_bars.get(&(date,symbol.into())).map(Vec::as_slice).unwrap_or(&[])
}
pub fn benchmark_series(&self) -> Vec<BenchmarkSnapshot> {
self.benchmark_by_date.values().cloned().collect()
}