收敛平台策略撮合模式
This commit is contained in:
@@ -420,14 +420,9 @@ fn normalize_model_name(value: &str) -> String {
|
|||||||
|
|
||||||
fn parse_matching_type(value: Option<&str>) -> Option<MatchingType> {
|
fn parse_matching_type(value: Option<&str>) -> Option<MatchingType> {
|
||||||
match normalize_model_name(value?).as_str() {
|
match normalize_model_name(value?).as_str() {
|
||||||
"open_auction" => Some(MatchingType::OpenAuction),
|
|
||||||
"current_bar_close" => Some(MatchingType::CurrentBarClose),
|
"current_bar_close" => Some(MatchingType::CurrentBarClose),
|
||||||
"next_bar_open" => Some(MatchingType::NextBarOpen),
|
"next_bar_open" => Some(MatchingType::NextBarOpen),
|
||||||
"minute_last" => Some(MatchingType::MinuteLast),
|
"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,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1675,6 +1670,48 @@ mod tests {
|
|||||||
assert!(cfg.strict_value_budget);
|
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]
|
#[test]
|
||||||
fn parses_dynamic_slippage_into_platform_config() {
|
fn parses_dynamic_slippage_into_platform_config() {
|
||||||
let spec = serde_json::json!({
|
let spec = serde_json::json!({
|
||||||
|
|||||||
Reference in New Issue
Block a user