From c094e78bef4cc135b499afb283870157cd692990 Mon Sep 17 00:00:00 2001 From: boris Date: Sun, 12 Jul 2026 01:45:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=91=A8=E6=9C=9F=E8=B0=83?= =?UTF-8?q?=E4=BB=93=E7=AD=89=E6=9D=83=E8=B5=84=E9=87=91=E9=A2=84=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fidc-core/src/platform_expr_strategy.rs | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/crates/fidc-core/src/platform_expr_strategy.rs b/crates/fidc-core/src/platform_expr_strategy.rs index 030b3b1..b034754 100644 --- a/crates/fidc-core/src/platform_expr_strategy.rs +++ b/crates/fidc-core/src/platform_expr_strategy.rs @@ -9397,12 +9397,8 @@ impl Strategy for PlatformExprStrategy { projected.cash() } }; - let fixed_buy_cash = if self.config.aiquant_transaction_cost { - aiquant_available_cash * trading_ratio / selection_limit as f64 - } else { - aiquant_total_value * trading_ratio / selection_limit as f64 - }; let target_budget = aiquant_total_value * trading_ratio; + let fixed_buy_cash = target_budget / selection_limit as f64; let mut rebalance_working_symbols = slot_working_symbols.clone(); if self.config.release_slot_on_exit_signal { for symbol in &same_day_sold_symbols { @@ -25285,7 +25281,7 @@ mod tests { } #[test] - fn platform_aiquant_periodic_rebalance_uses_cash_divided_by_top_n_buy_budget() { + fn platform_aiquant_periodic_rebalance_uses_total_equity_equal_weight_buy_budget() { let prev_date = d(2025, 5, 13); let date = d(2025, 5, 14); let retained_symbols = (1..=17) @@ -25484,12 +25480,28 @@ mod tests { "{:?}", decision.order_intents ); + let periodic_buy_values = decision + .order_intents + .iter() + .filter_map(|intent| match intent { + OrderIntent::Value { value, reason, .. } + if reason == "periodic_rebalance_buy" => Some(*value), + _ => None, + }) + .collect::>(); + let equal_weight_target = 5_060_000.0 / 40.0; assert!( - decision.order_intents.iter().all(|intent| match intent { - OrderIntent::Value { value, reason, .. } if reason == "periodic_rebalance_buy" => - (*value - 75_444.8).abs() < 1e-6, - _ => true, - }), + periodic_buy_values + .iter() + .take(periodic_buy_values.len().saturating_sub(1)) + .all(|value| (*value - equal_weight_target).abs() < 1e-6), + "{:?}", + decision.order_intents + ); + assert!( + periodic_buy_values + .last() + .is_some_and(|value| *value > 0.0 && *value <= equal_weight_target), "{:?}", decision.order_intents ); @@ -25646,7 +25658,7 @@ mod tests { reason, } if symbol == "000002.SZ" && reason == "periodic_rebalance_buy" - && (*value - 5_000.0).abs() < 1e-6 + && (*value - 10_000.0).abs() < 1e-6 )), "{:?}", decision.order_intents