From cd116bc3ae77cac0989eb80185bb04d7440b8834 Mon Sep 17 00:00:00 2001 From: boris Date: Sun, 30 Aug 2026 19:02:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=8F=E5=B0=91=E9=80=89=E8=82=A1=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=83=AD=E8=B7=AF=E5=BE=84=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E5=88=86=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fidc-core/src/platform_expr_strategy.rs | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/crates/fidc-core/src/platform_expr_strategy.rs b/crates/fidc-core/src/platform_expr_strategy.rs index 9ca70f8..d678d39 100644 --- a/crates/fidc-core/src/platform_expr_strategy.rs +++ b/crates/fidc-core/src/platform_expr_strategy.rs @@ -986,6 +986,7 @@ pub struct PlatformExprStrategy { prelude_identifier_candidates: BTreeSet, prelude_declared_identifiers: BTreeSet, stock_filter_quote_usage: StockFilterQuoteUsage, + stock_filter_expr_present: bool, selection_quote_usage: StockFilterQuoteUsage, stock_rolling_requirements: StockRollingRequirements, stock_extra_factors_required: bool, @@ -1259,6 +1260,7 @@ impl PlatformExprStrategy { Self::extract_identifier_candidates(&normalized_prelude); let prelude_declared_identifiers = Self::declared_prelude_identifiers(&config.prelude); let normalized_stock_filter_expr = Self::normalize_expr(&config.stock_filter_expr); + let stock_filter_expr_present = !normalized_stock_filter_expr.is_empty(); let stock_filter_quote_usage = Self::stock_filter_quote_usage_for_expr(&normalized_stock_filter_expr); let selection_quote_usage = @@ -1302,6 +1304,7 @@ impl PlatformExprStrategy { prelude_identifier_candidates, prelude_declared_identifiers, stock_filter_quote_usage, + stock_filter_expr_present, selection_quote_usage, stock_rolling_requirements, stock_extra_factors_required, @@ -8820,7 +8823,7 @@ impl PlatformExprStrategy { day: &DayExpressionState, stock: &StockExpressionState, ) -> Result { - if self.config.stock_filter_expr.trim().is_empty() { + if !self.stock_filter_expr_present { return Ok(true); } match self.eval_bool(ctx, &self.config.stock_filter_expr, day, Some(stock), None) { @@ -9064,6 +9067,9 @@ impl PlatformExprStrategy { } fn universe_exclude_reason(excludes: &[String], symbol: &str) -> Option<&'static str> { + if excludes.is_empty() { + return None; + } let normalized_symbol = symbol.trim().to_ascii_lowercase(); if normalized_symbol.is_empty() { return None; @@ -9085,8 +9091,15 @@ impl PlatformExprStrategy { } fn symbol_is_bjse(symbol: &str) -> bool { - let normalized = symbol.trim().to_ascii_uppercase(); - normalized.ends_with(".BJ") || normalized.ends_with(".BSE") || normalized.ends_with(".BE") + let normalized = symbol.trim(); + normalized + .get(normalized.len().saturating_sub(3)..) + .is_some_and(|suffix| { + suffix.eq_ignore_ascii_case(".BJ") || suffix.eq_ignore_ascii_case(".BE") + }) + || normalized + .get(normalized.len().saturating_sub(4)..) + .is_some_and(|suffix| suffix.eq_ignore_ascii_case(".BSE")) } fn stock_numeric_field_value( @@ -12257,6 +12270,20 @@ mod tests { PlatformExprStrategy::universe_exclude_reason(&excludes, "300001.SZ"), None ); + assert_eq!( + PlatformExprStrategy::universe_exclude_reason(&[], " 920508.bj "), + None + ); + } + + #[test] + fn bjse_symbol_detection_is_case_insensitive_without_normalizing_all_symbols() { + assert!(PlatformExprStrategy::symbol_is_bjse("920508.BJ")); + assert!(PlatformExprStrategy::symbol_is_bjse(" 920508.bj ")); + assert!(PlatformExprStrategy::symbol_is_bjse("430001.BSE")); + assert!(PlatformExprStrategy::symbol_is_bjse("430001.be")); + assert!(!PlatformExprStrategy::symbol_is_bjse("688001.SH")); + assert!(!PlatformExprStrategy::symbol_is_bjse("BJ")); } #[test]