支持回测数据集快照组件导出
This commit is contained in:
@@ -365,6 +365,17 @@ pub struct DailySnapshotBundle {
|
|||||||
pub corporate_actions: Vec<CorporateAction>,
|
pub corporate_actions: Vec<CorporateAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct DataSetSnapshotComponents {
|
||||||
|
pub instruments: Vec<Instrument>,
|
||||||
|
pub market: Vec<DailyMarketSnapshot>,
|
||||||
|
pub factors: Vec<DailyFactorSnapshot>,
|
||||||
|
pub candidates: Vec<CandidateEligibility>,
|
||||||
|
pub benchmarks: Vec<BenchmarkSnapshot>,
|
||||||
|
pub corporate_actions: Vec<CorporateAction>,
|
||||||
|
pub execution_quotes: Vec<IntradayExecutionQuote>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct PriceBar {
|
pub struct PriceBar {
|
||||||
#[serde(with = "date_format")]
|
#[serde(with = "date_format")]
|
||||||
@@ -1441,6 +1452,49 @@ impl DataSet {
|
|||||||
quotes
|
quotes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn snapshot_components(&self) -> DataSetSnapshotComponents {
|
||||||
|
let mut instruments = self.instruments.values().cloned().collect::<Vec<_>>();
|
||||||
|
instruments.sort_by(|left, right| left.symbol.cmp(&right.symbol));
|
||||||
|
|
||||||
|
let market = self
|
||||||
|
.market_by_date
|
||||||
|
.values()
|
||||||
|
.flat_map(|rows| rows.iter().cloned())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let factors = self
|
||||||
|
.factor_by_date
|
||||||
|
.values()
|
||||||
|
.flat_map(|rows| rows.iter().map(|row| row.as_ref().clone()))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let candidates = self
|
||||||
|
.candidate_by_date
|
||||||
|
.values()
|
||||||
|
.flat_map(|rows| rows.iter().map(|row| row.as_ref().clone()))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let benchmarks = self.benchmark_by_date.values().cloned().collect::<Vec<_>>();
|
||||||
|
let corporate_actions = self
|
||||||
|
.corporate_actions_by_date
|
||||||
|
.values()
|
||||||
|
.flat_map(|rows| rows.iter().cloned())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let execution_quotes = self
|
||||||
|
.execution_quotes_by_date
|
||||||
|
.values()
|
||||||
|
.flat_map(|rows_by_symbol| rows_by_symbol.values())
|
||||||
|
.flat_map(|rows| rows.iter().cloned())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
DataSetSnapshotComponents {
|
||||||
|
instruments,
|
||||||
|
market,
|
||||||
|
factors,
|
||||||
|
candidates,
|
||||||
|
benchmarks,
|
||||||
|
corporate_actions,
|
||||||
|
execution_quotes,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn benchmark_series(&self) -> Vec<BenchmarkSnapshot> {
|
pub fn benchmark_series(&self) -> Vec<BenchmarkSnapshot> {
|
||||||
self.benchmark_by_date.values().cloned().collect()
|
self.benchmark_by_date.values().cloned().collect()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user