From dd8783c8c1b286a32cc5339d817f8f8dd1080611 Mon Sep 17 00:00:00 2001 From: boris Date: Sun, 28 Jun 2026 01:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E6=95=9B=E5=B9=B3=E5=8F=B0=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E6=92=AE=E5=90=88=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fidc-core/src/platform_strategy_spec.rs | 47 +++++++++++++++++-- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/crates/fidc-core/src/platform_strategy_spec.rs b/crates/fidc-core/src/platform_strategy_spec.rs index 2e026e1..e244c16 100644 --- a/crates/fidc-core/src/platform_strategy_spec.rs +++ b/crates/fidc-core/src/platform_strategy_spec.rs @@ -420,14 +420,9 @@ fn normalize_model_name(value: &str) -> String { fn parse_matching_type(value: Option<&str>) -> Option { match normalize_model_name(value?).as_str() { - "open_auction" => Some(MatchingType::OpenAuction), "current_bar_close" => Some(MatchingType::CurrentBarClose), "next_bar_open" => Some(MatchingType::NextBarOpen), "minute_last" => Some(MatchingType::MinuteLast), - "minute_best_own" => Some(MatchingType::MinuteBestOwn), - "minute_best_counterparty" => Some(MatchingType::MinuteBestCounterparty), - "vwap" => Some(MatchingType::Vwap), - "twap" => Some(MatchingType::Twap), _ => None, } } @@ -1675,6 +1670,48 @@ mod tests { assert!(cfg.strict_value_budget); } + #[test] + fn platform_spec_accepts_only_supported_matching_types() { + for (raw, expected) in [ + ("current_bar_close", MatchingType::CurrentBarClose), + ("next_bar_open", MatchingType::NextBarOpen), + ("minute_last", MatchingType::MinuteLast), + ] { + let spec = serde_json::json!({ + "execution": { + "matchingType": raw + } + }); + + let cfg = platform_expr_config_from_value("", "", &spec).expect("config"); + + assert_eq!(cfg.matching_type, expected); + } + + for raw in [ + "open_auction", + "minute_best_own", + "minute_best_counterparty", + "vwap", + "twap", + "current_close", + "next_open", + ] { + let spec = serde_json::json!({ + "execution": { + "matchingType": raw + }, + "engineConfig": { + "matchingType": "current_bar_close" + } + }); + + let cfg = platform_expr_config_from_value("", "", &spec).expect("config"); + + assert_eq!(cfg.matching_type, MatchingType::CurrentBarClose); + } + } + #[test] fn parses_dynamic_slippage_into_platform_config() { let spec = serde_json::json!({