diff --git a/crates/fidc-core/src/platform_strategy_spec.rs b/crates/fidc-core/src/platform_strategy_spec.rs index 71574c9..ddbd8a1 100644 --- a/crates/fidc-core/src/platform_strategy_spec.rs +++ b/crates/fidc-core/src/platform_strategy_spec.rs @@ -1999,6 +1999,10 @@ fn instrument_query_id(symbol: &str, board: &str) -> String { } fn normalize_board(symbol: &str, raw_board: Option<&str>) -> String { + let has_suffix = symbol.trim().rsplit_once('.').is_some(); + if has_suffix && symbol_is_kcb(symbol) { + return "KSH".to_string(); + } let normalized = raw_board .map(str::trim) .filter(|value| !value.is_empty()) @@ -2011,7 +2015,7 @@ fn normalize_board(symbol: &str, raw_board: Option<&str>) -> String { if let Some((_, suffix)) = symbol.rsplit_once('.') { return suffix.to_ascii_uppercase(); } - if symbol.starts_with("688") { + if symbol_is_kcb(symbol) { return "KSH".to_string(); } if symbol.starts_with('8') || symbol.starts_with('4') { @@ -2030,10 +2034,29 @@ fn normalize_board(symbol: &str, raw_board: Option<&str>) -> String { "UNK".to_string() } +fn symbol_is_kcb(symbol: &str) -> bool { + let normalized = symbol.trim().to_ascii_uppercase(); + let Some((code, suffix)) = normalized.rsplit_once('.') else { + return normalized.starts_with("688") || normalized.starts_with("689"); + }; + suffix == "SH" && (code.starts_with("688") || code.starts_with("689")) +} + #[cfg(test)] mod tests { use super::*; + #[test] + fn normalize_board_classifies_kcb_by_688_689_sh_suffix_only() { + assert_eq!(normalize_board("688001.SH", None), "KSH"); + assert_eq!(normalize_board("689001.SH", None), "KSH"); + assert_eq!(normalize_board("688001.BJ", None), "BJ"); + assert_eq!(normalize_board("689001.SZ", None), "SZ"); + assert_eq!(normalize_board("688001", None), "KSH"); + assert_eq!(normalize_board("688001", Some("SZ")), "SZ"); + assert_eq!(normalize_board("688001.SH", Some("SH")), "KSH"); + } + #[test] fn parses_runtime_expression_spec_into_platform_config() { let spec = serde_json::json!({