仅在成功清仓后释放目标权重

This commit is contained in:
boris
2026-09-07 03:59:48 +08:00
parent f9d9f06d3f
commit 27e523a1dc
+15 -11
View File
@@ -12533,7 +12533,7 @@ impl Strategy for PlatformExprStrategy {
} }
let stop_take_exit_signal_symbols = current_stop_take_exit_symbols.clone(); let stop_take_exit_signal_symbols = current_stop_take_exit_symbols.clone();
let target_portfolio_weights = let original_target_weights =
if self.config.target_portfolio_daily_enabled && selection_limit > 0 { if self.config.target_portfolio_daily_enabled && selection_limit > 0 {
let mut scales = Vec::new(); let mut scales = Vec::new();
let original_target_symbols = self let original_target_symbols = self
@@ -12557,18 +12557,16 @@ impl Strategy for PlatformExprStrategy {
)?; )?;
scales.push((symbol.clone(), self.buy_scale(ctx, &day, &decision_stock)?)); scales.push((symbol.clone(), self.buy_scale(ctx, &day, &decision_stock)?));
} }
let original_weights = ordered_weight_bps_from_scales(&scales)?; ordered_weight_bps_from_scales(&scales)?
let mut excluded_target_symbols = exit_symbols.clone();
excluded_target_symbols.extend(stop_take_exit_signal_symbols.iter().cloned());
replenish_target_weight_bps(
&original_weights,
&stock_list,
&excluded_target_symbols,
selection_limit,
)
} else { } else {
Vec::new() Vec::new()
}; };
let target_portfolio_weights = replenish_target_weight_bps(
&original_target_weights,
&stock_list,
&exit_symbols,
selection_limit,
);
let target_portfolio_weight_bps = target_portfolio_weights let target_portfolio_weight_bps = target_portfolio_weights
.iter() .iter()
.cloned() .cloned()
@@ -13147,8 +13145,14 @@ impl Strategy for PlatformExprStrategy {
} }
} }
let daily_target_portfolio_weights = replenish_target_weight_bps(
&original_target_weights,
&stock_list,
&same_day_sold_symbols,
selection_limit,
);
if daily_top_up_active && self.config.target_portfolio_daily_enabled { if daily_top_up_active && self.config.target_portfolio_daily_enabled {
for (symbol, weight_bps) in &target_portfolio_weights { for (symbol, weight_bps) in &daily_target_portfolio_weights {
let target_value = let target_value =
strategy_visible_total_value * trading_ratio * f64::from(*weight_bps) strategy_visible_total_value * trading_ratio * f64::from(*weight_bps)
/ 10_000.0; / 10_000.0;