From c18306aed9429592fc73f0da9e6c0730816c72df Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 26 Aug 2026 13:59:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=BB=B6=E8=BF=9F=E8=B5=84?= =?UTF-8?q?=E9=87=91=E5=88=B0=E8=B4=A6=E8=A1=A8=E8=BE=BE=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 | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/crates/fidc-core/src/platform_strategy_spec.rs b/crates/fidc-core/src/platform_strategy_spec.rs index 63207e7..4c9bbbf 100644 --- a/crates/fidc-core/src/platform_strategy_spec.rs +++ b/crates/fidc-core/src/platform_strategy_spec.rs @@ -777,6 +777,8 @@ pub struct StrategyExpressionActionConfig { pub symbols_expr: Option, #[serde(default)] pub amount_expr: Option, + #[serde(default, alias = "receiving_days_expr")] + pub receiving_days_expr: Option, #[serde(default)] pub direction: Option, #[serde(default)] @@ -2413,7 +2415,12 @@ fn parse_platform_trade_action( .map(str::trim) .filter(|value| !value.is_empty())? .to_string(), - receiving_days_expr: None, + receiving_days_expr: action + .receiving_days_expr + .as_deref() + .map(str::trim) + .filter(|value| !value.is_empty()) + .map(ToString::to_string), when_expr, reason, }), @@ -2641,6 +2648,39 @@ mod tests { assert_eq!(cfg.explicit_actions.len(), 1); } + #[test] + fn parses_delayed_deposit_receiving_days_expression() { + let spec = serde_json::json!({ + "runtimeExpressions": { + "trading": { + "rotationEnabled": false, + "actions": [{ + "kind": "deposit_withdraw", + "amountExpr": "1000", + "receivingDaysExpr": "1", + "reason": "delayed capital injection" + }] + } + } + }); + + let cfg = platform_expr_config_from_value("cash-flow", "000300.SH", &spec) + .expect("delayed deposit config"); + + assert!(matches!( + cfg.explicit_actions.as_slice(), + [PlatformTradeAction::Account { + kind: PlatformAccountActionKind::DepositWithdraw, + amount_expr, + receiving_days_expr: Some(receiving_days_expr), + reason, + .. + }] if amount_expr == "1000" + && receiving_days_expr == "1" + && reason == "delayed capital injection" + )); + } + #[test] fn parses_generic_futures_actions_and_rejects_incomplete_contracts() { let spec = serde_json::json!({