保留延迟资金到账表达式
This commit is contained in:
@@ -777,6 +777,8 @@ pub struct StrategyExpressionActionConfig {
|
|||||||
pub symbols_expr: Option<String>,
|
pub symbols_expr: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub amount_expr: Option<String>,
|
pub amount_expr: Option<String>,
|
||||||
|
#[serde(default, alias = "receiving_days_expr")]
|
||||||
|
pub receiving_days_expr: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub direction: Option<String>,
|
pub direction: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -2413,7 +2415,12 @@ fn parse_platform_trade_action(
|
|||||||
.map(str::trim)
|
.map(str::trim)
|
||||||
.filter(|value| !value.is_empty())?
|
.filter(|value| !value.is_empty())?
|
||||||
.to_string(),
|
.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,
|
when_expr,
|
||||||
reason,
|
reason,
|
||||||
}),
|
}),
|
||||||
@@ -2641,6 +2648,39 @@ mod tests {
|
|||||||
assert_eq!(cfg.explicit_actions.len(), 1);
|
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]
|
#[test]
|
||||||
fn parses_generic_futures_actions_and_rejects_incomplete_contracts() {
|
fn parses_generic_futures_actions_and_rejects_incomplete_contracts() {
|
||||||
let spec = serde_json::json!({
|
let spec = serde_json::json!({
|
||||||
|
|||||||
Reference in New Issue
Block a user