保留延迟资金到账表达式
This commit is contained in:
@@ -777,6 +777,8 @@ pub struct StrategyExpressionActionConfig {
|
||||
pub symbols_expr: Option<String>,
|
||||
#[serde(default)]
|
||||
pub amount_expr: Option<String>,
|
||||
#[serde(default, alias = "receiving_days_expr")]
|
||||
pub receiving_days_expr: Option<String>,
|
||||
#[serde(default)]
|
||||
pub direction: Option<String>,
|
||||
#[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!({
|
||||
|
||||
Reference in New Issue
Block a user