统一策略规范科创板归类
This commit is contained in:
@@ -1999,6 +1999,10 @@ fn instrument_query_id(symbol: &str, board: &str) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn normalize_board(symbol: &str, raw_board: Option<&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
|
let normalized = raw_board
|
||||||
.map(str::trim)
|
.map(str::trim)
|
||||||
.filter(|value| !value.is_empty())
|
.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('.') {
|
if let Some((_, suffix)) = symbol.rsplit_once('.') {
|
||||||
return suffix.to_ascii_uppercase();
|
return suffix.to_ascii_uppercase();
|
||||||
}
|
}
|
||||||
if symbol.starts_with("688") {
|
if symbol_is_kcb(symbol) {
|
||||||
return "KSH".to_string();
|
return "KSH".to_string();
|
||||||
}
|
}
|
||||||
if symbol.starts_with('8') || symbol.starts_with('4') {
|
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()
|
"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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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]
|
#[test]
|
||||||
fn parses_runtime_expression_spec_into_platform_config() {
|
fn parses_runtime_expression_spec_into_platform_config() {
|
||||||
let spec = serde_json::json!({
|
let spec = serde_json::json!({
|
||||||
|
|||||||
Reference in New Issue
Block a user