收敛平台策略撮合模式

This commit is contained in:
boris
2026-06-28 01:16:38 +08:00
parent 9562b8a280
commit dd8783c8c1
+42 -5
View File
@@ -420,14 +420,9 @@ fn normalize_model_name(value: &str) -> String {
fn parse_matching_type(value: Option<&str>) -> Option<MatchingType> {
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!({