对齐 AiQuant RQAlpha 回测语义

This commit is contained in:
boris
2026-05-15 11:48:10 +08:00
parent 94662b6e75
commit 4577657c90
7 changed files with 1377 additions and 69 deletions
+14
View File
@@ -654,6 +654,14 @@ impl SymbolPriceSeries {
self.values_for(field).get(end - 1).copied()
}
fn snapshot_before(&self, date: NaiveDate) -> Option<&DailyMarketSnapshot> {
let end = self.previous_completed_end_index(date)?;
if end == 0 {
return None;
}
self.snapshots.get(end - 1)
}
fn prefix_for(&self, field: PriceField) -> &[f64] {
match field {
PriceField::DayOpen => &self.open_prefix,
@@ -1828,6 +1836,12 @@ impl DataSet {
.and_then(|series| series.price_on_or_before(date, field))
}
pub fn market_before(&self, date: NaiveDate, symbol: &str) -> Option<&DailyMarketSnapshot> {
self.market_series_by_symbol
.get(symbol)
.and_then(|series| series.snapshot_before(date))
}
pub fn factor_snapshots_on(&self, date: NaiveDate) -> Vec<&DailyFactorSnapshot> {
self.factor_by_date
.get(&date)