修正周期调仓等权资金预算
This commit is contained in:
@@ -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::<Vec<_>>();
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user