阻止未完成退出反向补买
This commit is contained in:
@@ -13280,6 +13280,13 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
)?;
|
)?;
|
||||||
if daily_top_up_active && self.config.target_portfolio_daily_enabled {
|
if daily_top_up_active && self.config.target_portfolio_daily_enabled {
|
||||||
for (symbol, target_scale) in &daily_target_portfolio_scales {
|
for (symbol, target_scale) in &daily_target_portfolio_scales {
|
||||||
|
if exit_symbols.contains(symbol)
|
||||||
|
|| pending_full_close_symbols.contains(symbol)
|
||||||
|
|| factor_position_action_symbols.contains(symbol)
|
||||||
|
|| delayed_sold_symbols.contains(symbol)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let target_value = target_value_for_scale(
|
let target_value = target_value_for_scale(
|
||||||
strategy_visible_total_value,
|
strategy_visible_total_value,
|
||||||
trading_ratio,
|
trading_ratio,
|
||||||
@@ -22682,12 +22689,19 @@ mod tests {
|
|||||||
cfg.risk_config.trading_constraints.liquidity_limit_enabled = true;
|
cfg.risk_config.trading_constraints.liquidity_limit_enabled = true;
|
||||||
cfg.signal_symbol = symbol.to_string();
|
cfg.signal_symbol = symbol.to_string();
|
||||||
cfg.exposure_expr = "0.5".to_string();
|
cfg.exposure_expr = "0.5".to_string();
|
||||||
cfg.selection_limit_expr = "40".to_string();
|
cfg.max_positions = 1;
|
||||||
cfg.stock_filter_expr = "false".to_string();
|
cfg.selection_limit_expr = "1".to_string();
|
||||||
|
cfg.stock_filter_expr = "close > 0".to_string();
|
||||||
cfg.stop_loss_expr = "0.92".to_string();
|
cfg.stop_loss_expr = "0.92".to_string();
|
||||||
cfg.take_profit_expr.clear();
|
cfg.take_profit_expr.clear();
|
||||||
|
cfg.daily_top_up_enabled = true;
|
||||||
|
cfg.daily_position_target_adjust_enabled = true;
|
||||||
|
cfg.target_portfolio_daily_enabled = true;
|
||||||
|
cfg.release_slot_on_exit_signal = true;
|
||||||
|
cfg.redistribute_target_weights_after_exit = true;
|
||||||
cfg.intraday_execution_time = Some(NaiveTime::from_hms_opt(10, 15, 0).expect("time"));
|
cfg.intraday_execution_time = Some(NaiveTime::from_hms_opt(10, 15, 0).expect("time"));
|
||||||
let mut strategy = PlatformExprStrategy::new(cfg);
|
let mut strategy = PlatformExprStrategy::new(cfg);
|
||||||
|
strategy.rebalance_day_counter = 2;
|
||||||
|
|
||||||
let decision = strategy.on_day(&ctx).expect("platform decision");
|
let decision = strategy.on_day(&ctx).expect("platform decision");
|
||||||
|
|
||||||
@@ -22709,6 +22723,14 @@ mod tests {
|
|||||||
&& *quantity > 0
|
&& *quantity > 0
|
||||||
&& reason == "daily_position_target_adjust"
|
&& reason == "daily_position_target_adjust"
|
||||||
)));
|
)));
|
||||||
|
assert!(!decision.order_intents.iter().any(|intent| matches!(
|
||||||
|
intent,
|
||||||
|
OrderIntent::TargetValue {
|
||||||
|
symbol: intent_symbol,
|
||||||
|
target_value,
|
||||||
|
..
|
||||||
|
} if intent_symbol == symbol && *target_value > 0.0
|
||||||
|
)));
|
||||||
assert!(!strategy.pending_full_close_symbols.contains(symbol));
|
assert!(!strategy.pending_full_close_symbols.contains(symbol));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user