From 144483be4cd06bb2d506808b49143e4391f1a219 Mon Sep 17 00:00:00 2001 From: boris Date: Sat, 20 Jun 2026 19:24:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B9=B0=E5=85=A5=E7=A6=81?= =?UTF-8?q?=E5=85=A5=E8=AF=AF=E8=A7=A6=E5=8F=91=E5=BC=BA=E5=B9=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fidc-core/src/platform_expr_strategy.rs | 78 +------------------ 1 file changed, 4 insertions(+), 74 deletions(-) diff --git a/crates/fidc-core/src/platform_expr_strategy.rs b/crates/fidc-core/src/platform_expr_strategy.rs index 3c2d223..95aa23d 100644 --- a/crates/fidc-core/src/platform_expr_strategy.rs +++ b/crates/fidc-core/src/platform_expr_strategy.rs @@ -2198,17 +2198,6 @@ impl PlatformExprStrategy { } } - fn candidate_requires_forced_exit( - &self, - ctx: &StrategyContext<'_>, - date: NaiveDate, - symbol: &str, - ) -> bool { - ctx.data.candidate(date, symbol).is_some_and(|candidate| { - !candidate.allow_buy && candidate.allow_sell && !candidate.is_paused - }) - } - fn stock_state_with_factor_date_and_time( &self, ctx: &StrategyContext<'_>, @@ -6831,10 +6820,6 @@ impl Strategy for PlatformExprStrategy { )? { continue; } - if self.candidate_requires_forced_exit(ctx, execution_date, &position.symbol) { - pending_full_close_symbols.insert(position.symbol.clone()); - continue; - } let (stop_hit, profit_hit) = self.stop_take_action_for_position(ctx, execution_date, &day, position)?; if stop_hit { @@ -6869,52 +6854,6 @@ impl Strategy for PlatformExprStrategy { } } - if self.config.aiquant_transaction_cost { - for position in ctx.portfolio.positions().values() { - if position.quantity == 0 || delayed_sold_symbols.contains(&position.symbol) { - continue; - } - if !pending_full_close_symbols.contains(&position.symbol) - || !self.candidate_requires_forced_exit(ctx, execution_date, &position.symbol) - { - continue; - } - if self.regular_sell_should_wait_due_to_highlimit( - ctx, - execution_date, - &position.symbol, - self.intraday_execution_start_time(), - )? { - continue; - } - let can_sell = self.can_sell_position(ctx, execution_date, &position.symbol); - exit_symbols.insert(position.symbol.clone()); - order_intents.push(OrderIntent::TargetValue { - symbol: position.symbol.clone(), - target_value: 0.0, - reason: "risk_forced_exit".to_string(), - }); - if can_sell { - if self - .project_target_zero( - ctx, - &mut projected, - execution_date, - &position.symbol, - &mut projected_execution_state, - ) - .is_some() - && Self::projected_position_is_flat(&projected, &position.symbol) - { - same_day_sold_symbols.insert(position.symbol.clone()); - slot_working_symbols.remove(&position.symbol); - } - } else { - unresolved_stop_loss_symbols.insert(position.symbol.clone()); - } - } - } - if self.config.aiquant_transaction_cost && self.config.rotation_enabled && trading_ratio > 0.0 @@ -10737,7 +10676,7 @@ mod tests { } #[test] - fn platform_aiquant_forced_risk_exit_precedes_weak_market_shrink() { + fn platform_aiquant_buy_disabled_does_not_force_exit_existing_position() { let date = d(2023, 5, 5); let symbol = "300621.SZ"; let data = DataSet::from_components( @@ -10829,17 +10768,16 @@ mod tests { let mut cfg = PlatformExprStrategyConfig::microcap_rotation(); cfg.aiquant_transaction_cost = true; cfg.signal_symbol = symbol.to_string(); - cfg.exposure_expr = "0.5".to_string(); + cfg.exposure_expr = "1.0".to_string(); cfg.selection_limit_expr = "40".to_string(); - cfg.stock_filter_expr = "false".to_string(); + cfg.stock_filter_expr = "true".to_string(); cfg.stop_loss_expr.clear(); cfg.take_profit_expr.clear(); - cfg.weak_market_shrink_overweight_threshold = Some(1.10); let mut strategy = PlatformExprStrategy::new(cfg); let decision = strategy.on_day(&ctx).expect("platform decision"); - assert!(decision.order_intents.iter().any(|intent| matches!( + assert!(!decision.order_intents.iter().any(|intent| matches!( intent, OrderIntent::TargetValue { symbol: intent_symbol, @@ -10847,14 +10785,6 @@ mod tests { reason, } if intent_symbol == symbol && *target_value == 0.0 && reason == "risk_forced_exit" ))); - assert!(!decision.order_intents.iter().any(|intent| matches!( - intent, - OrderIntent::Shares { - symbol: intent_symbol, - reason, - .. - } if intent_symbol == symbol && reason == "daily_position_target_adjust" - ))); } #[test]