修复平台策略金额买入预算

This commit is contained in:
boris
2026-06-17 19:35:19 +08:00
parent d8b6130428
commit 6c7f7130cf
+6 -30
View File
@@ -6876,20 +6876,12 @@ impl Strategy for PlatformExprStrategy {
&mut projected_execution_state,
);
if filled_qty > 0 {
if self.config.aiquant_transaction_cost {
order_intents.push(OrderIntent::Shares {
symbol: symbol.clone(),
quantity: filled_qty as i32,
reason: "daily_top_up_buy".to_string(),
});
} else {
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "daily_top_up_buy".to_string(),
});
}
}
if filled_qty > 0 {
let spent = (cash_before_buy - projected.cash()).max(0.0);
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
@@ -7005,19 +6997,11 @@ impl Strategy for PlatformExprStrategy {
&mut projected_execution_state,
);
if filled_qty > 0 {
if self.config.aiquant_transaction_cost {
order_intents.push(OrderIntent::Shares {
symbol: symbol.clone(),
quantity: filled_qty as i32,
reason: "periodic_rebalance_buy".to_string(),
});
} else {
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "periodic_rebalance_buy".to_string(),
});
}
let spent = (cash_before_buy - projected.cash()).max(0.0);
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
intraday_attempted_buys.insert(symbol.clone());
@@ -7073,19 +7057,11 @@ impl Strategy for PlatformExprStrategy {
&mut projected_execution_state,
);
if filled_qty > 0 {
if self.config.aiquant_transaction_cost {
order_intents.push(OrderIntent::Shares {
symbol: symbol.clone(),
quantity: filled_qty as i32,
reason: "periodic_rebalance_buy".to_string(),
});
} else {
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "periodic_rebalance_buy".to_string(),
});
}
let spent = (cash_before_buy - projected.cash()).max(0.0);
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
rebalance_working_symbols.insert(symbol.clone());
@@ -14233,11 +14209,11 @@ mod tests {
assert!(
decision.order_intents.iter().any(|intent| matches!(
intent,
OrderIntent::Shares {
OrderIntent::Value {
symbol,
quantity,
value,
reason,
} if symbol == "000003.SZ" && *quantity > 0 && reason == "daily_top_up_buy"
} if symbol == "000003.SZ" && *value > 0.0 && reason == "daily_top_up_buy"
)),
"{:?}",
decision.order_intents
@@ -14867,13 +14843,13 @@ mod tests {
assert!(
decision.order_intents.iter().any(|intent| matches!(
intent,
OrderIntent::Shares {
OrderIntent::Value {
symbol,
quantity,
value,
reason,
} if symbol == "000002.SZ"
&& reason == "periodic_rebalance_buy"
&& *quantity == 900
&& (*value - 10_000.0).abs() < 1e-6
)),
"{:?}",
decision.order_intents