对齐 AiQuant RQAlpha 回测语义
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user