修复延迟执行选股风控语义
This commit is contained in:
@@ -2506,6 +2506,10 @@ impl DataSet {
|
||||
.unwrap_or(&[])
|
||||
}
|
||||
|
||||
pub fn fundamental_universe_on(&self, date: NaiveDate) -> Vec<EligibleUniverseSnapshot> {
|
||||
build_fundamental_universe_for_date(date, &self.factor_by_date, &self.market_by_date)
|
||||
}
|
||||
|
||||
pub fn eligible_universe_on_with_risk_config(
|
||||
&self,
|
||||
date: NaiveDate,
|
||||
@@ -3051,6 +3055,41 @@ fn build_eligible_universe(
|
||||
per_date
|
||||
}
|
||||
|
||||
fn build_fundamental_universe_for_date(
|
||||
date: NaiveDate,
|
||||
factor_by_date: &BTreeMap<NaiveDate, Vec<Arc<DailyFactorSnapshot>>>,
|
||||
market_by_date: &BTreeMap<NaiveDate, Vec<Arc<DailyMarketSnapshot>>>,
|
||||
) -> Vec<EligibleUniverseSnapshot> {
|
||||
let mut rows = Vec::new();
|
||||
let Some(factors) = factor_by_date.get(&date) else {
|
||||
return rows;
|
||||
};
|
||||
for factor in factors {
|
||||
let Some(market) = market_by_date
|
||||
.get(&date)
|
||||
.and_then(|rows| find_arc_by_symbol(rows, &factor.symbol, |row| row.symbol.as_str()))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let market_cap_bn = decision_market_cap_bn(factor, market);
|
||||
if market_cap_bn <= 0.0 || !market_cap_bn.is_finite() {
|
||||
continue;
|
||||
}
|
||||
rows.push(EligibleUniverseSnapshot {
|
||||
symbol: factor.symbol.clone(),
|
||||
market_cap_bn,
|
||||
free_float_cap_bn: decision_free_float_cap_bn(factor, market),
|
||||
});
|
||||
}
|
||||
rows.sort_by(|left, right| {
|
||||
left.market_cap_bn
|
||||
.partial_cmp(&right.market_cap_bn)
|
||||
.unwrap_or(std::cmp::Ordering::Equal)
|
||||
.then_with(|| left.symbol.cmp(&right.symbol))
|
||||
});
|
||||
rows
|
||||
}
|
||||
|
||||
fn build_eligible_universe_for_date(
|
||||
date: NaiveDate,
|
||||
factor_by_date: &BTreeMap<NaiveDate, Vec<Arc<DailyFactorSnapshot>>>,
|
||||
|
||||
Reference in New Issue
Block a user