减少日频数据读取临时分配
This commit is contained in:
@@ -2456,6 +2456,13 @@ impl DataSet {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn market_snapshot_rows_on(&self, date: NaiveDate) -> &[DailyMarketSnapshot] {
|
||||||
|
self.market_by_date
|
||||||
|
.get(&date)
|
||||||
|
.map(Vec::as_slice)
|
||||||
|
.unwrap_or(&[])
|
||||||
|
}
|
||||||
|
|
||||||
pub fn candidate_snapshots_on(&self, date: NaiveDate) -> Vec<&CandidateEligibility> {
|
pub fn candidate_snapshots_on(&self, date: NaiveDate) -> Vec<&CandidateEligibility> {
|
||||||
self.candidate_by_date
|
self.candidate_by_date
|
||||||
.get(&date)
|
.get(&date)
|
||||||
@@ -2463,6 +2470,13 @@ impl DataSet {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn candidate_snapshot_rows_on(&self, date: NaiveDate) -> &[CandidateEligibility] {
|
||||||
|
self.candidate_by_date
|
||||||
|
.get(&date)
|
||||||
|
.map(Vec::as_slice)
|
||||||
|
.unwrap_or(&[])
|
||||||
|
}
|
||||||
|
|
||||||
pub fn bundle_on(&self, date: NaiveDate) -> Result<DailySnapshotBundle, DataSetError> {
|
pub fn bundle_on(&self, date: NaiveDate) -> Result<DailySnapshotBundle, DataSetError> {
|
||||||
let benchmark = self
|
let benchmark = self
|
||||||
.benchmark(date)
|
.benchmark(date)
|
||||||
|
|||||||
@@ -1778,11 +1778,11 @@ where
|
|||||||
.filter(|date| self.config.end_date.map(|end| *date <= end).unwrap_or(true))
|
.filter(|date| self.config.end_date.map(|end| *date <= end).unwrap_or(true))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let has_decision_inputs = |date: NaiveDate| {
|
let has_decision_inputs = |date: NaiveDate| {
|
||||||
!self.data.factor_snapshots_on(date).is_empty()
|
!self.data.factor_snapshot_rows_on(date).is_empty()
|
||||||
&& !self.data.candidate_snapshots_on(date).is_empty()
|
&& !self.data.candidate_snapshot_rows_on(date).is_empty()
|
||||||
};
|
};
|
||||||
let has_execution_market =
|
let has_execution_market =
|
||||||
|date: NaiveDate| !self.data.market_snapshots_on(date).is_empty();
|
|date: NaiveDate| !self.data.market_snapshot_rows_on(date).is_empty();
|
||||||
let mut execution_dates = Vec::new();
|
let mut execution_dates = Vec::new();
|
||||||
let mut decision_slots = Vec::new();
|
let mut decision_slots = Vec::new();
|
||||||
for (calendar_idx, execution_date) in calendar_dates.iter().copied().enumerate() {
|
for (calendar_idx, execution_date) in calendar_dates.iter().copied().enumerate() {
|
||||||
|
|||||||
@@ -3678,8 +3678,8 @@ impl PlatformExprStrategy {
|
|||||||
is_month_end,
|
is_month_end,
|
||||||
available_factor_names: if self.stock_extra_factors_required {
|
available_factor_names: if self.stock_extra_factors_required {
|
||||||
ctx.data
|
ctx.data
|
||||||
.factor_snapshots_on(date)
|
.factor_snapshot_rows_on(date)
|
||||||
.into_iter()
|
.iter()
|
||||||
.flat_map(|row| row.extra_factors.keys().map(|key| key.to_string()))
|
.flat_map(|row| row.extra_factors.keys().map(|key| key.to_string()))
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
@@ -7797,7 +7797,7 @@ impl PlatformExprStrategy {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let mut map = Map::new();
|
let mut map = Map::new();
|
||||||
for snapshot in ctx.data.market_snapshots_on(date) {
|
for snapshot in ctx.data.market_snapshot_rows_on(date) {
|
||||||
if let Some(value) = Self::market_scope_value(snapshot, field) {
|
if let Some(value) = Self::market_scope_value(snapshot, field) {
|
||||||
map.insert(snapshot.symbol.clone().into(), Dynamic::from(value));
|
map.insert(snapshot.symbol.clone().into(), Dynamic::from(value));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2541,7 +2541,7 @@ impl OmniMicroCapStrategy {
|
|||||||
date: NaiveDate,
|
date: NaiveDate,
|
||||||
) -> Vec<FidcRiskDecisionAudit> {
|
) -> Vec<FidcRiskDecisionAudit> {
|
||||||
let mut decisions = Vec::new();
|
let mut decisions = Vec::new();
|
||||||
for factor in ctx.data.factor_snapshots_on(date) {
|
for factor in ctx.data.factor_snapshot_rows_on(date) {
|
||||||
if ctx.has_dynamic_universe() && !ctx.dynamic_universe_contains(&factor.symbol) {
|
if ctx.has_dynamic_universe() && !ctx.dynamic_universe_contains(&factor.symbol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ impl SelectionContext<'_> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mut decisions = Vec::new();
|
let mut decisions = Vec::new();
|
||||||
for factor in self.data.factor_snapshots_on(self.decision_date) {
|
for factor in self.data.factor_snapshot_rows_on(self.decision_date) {
|
||||||
if self
|
if self
|
||||||
.dynamic_universe
|
.dynamic_universe
|
||||||
.is_some_and(|symbols| !symbols.is_empty() && !symbols.contains(&factor.symbol))
|
.is_some_and(|symbols| !symbols.is_empty() && !symbols.contains(&factor.symbol))
|
||||||
@@ -213,7 +213,7 @@ impl UniverseSelector for DynamicMarketCapBandSelector {
|
|||||||
risk_decisions: Vec::new(),
|
risk_decisions: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
diagnostics.factor_total = ctx.data.factor_snapshots_on(ctx.decision_date).len();
|
diagnostics.factor_total = ctx.data.factor_snapshot_rows_on(ctx.decision_date).len();
|
||||||
diagnostics.risk_decisions = ctx.selection_risk_decisions();
|
diagnostics.risk_decisions = ctx.selection_risk_decisions();
|
||||||
diagnostics.not_eligible_count = diagnostics.risk_decisions.len();
|
diagnostics.not_eligible_count = diagnostics.risk_decisions.len();
|
||||||
diagnostics.paused_count = diagnostics
|
diagnostics.paused_count = diagnostics
|
||||||
|
|||||||
Reference in New Issue
Block a user