接入完整市场与申万行业事件研究内核

This commit is contained in:
boris
2026-09-10 13:35:46 +08:00
parent 999bf5bd01
commit 7dcaae594a
5 changed files with 260 additions and 3 deletions
+7 -3
View File
@@ -737,8 +737,10 @@ pub fn evaluate_research_batch_with_policy(
spec: PatternSpec, days: &[NaiveDate], series: &[PatternSeries],
context: &ResearchContext, numeric_output: bool, isolate_data_errors: bool,
) -> Result<Value, String> {
let common_fields = ["index_open", "index_high", "index_low", "index_close"];
let symbol_fields = ["scope_rank", "scope_percentile", "scope_size"];
let common_fields = ["index_open", "index_high", "index_low", "index_close"].into_iter()
.chain(crate::market_event_context::COMMON_FIELDS.iter().copied()).collect::<Vec<_>>();
let symbol_fields = ["scope_rank", "scope_percentile", "scope_size"].into_iter()
.chain(crate::market_event_context::INDUSTRY_FIELDS.iter().copied()).collect::<Vec<_>>();
if spec.template != "expression" || series.is_empty() || series.len() > 200
|| series.iter().map(|s| &s.symbol).collect::<BTreeSet<_>>().len() != series.len()
|| context.common.keys().any(|k| !common_fields.contains(&k.as_str()))
@@ -747,7 +749,9 @@ pub fn evaluate_research_batch_with_policy(
return Err("research_context_scope_or_fields_invalid".into());
}
for (name, values) in &context.common {
if values.len() != days.len() || values.iter().any(|v| !v.is_some_and(|x| x.is_finite() && x > 0.0)) {
if values.len() != days.len() || values.iter().any(|v| if name.starts_with("index_") {
!v.is_some_and(|x| x.is_finite() && x > 0.0)
} else { v.is_some_and(|x| !x.is_finite()) }) {
return Err(format!("research_index_window_incomplete: {name}"));
}
}