对齐目标组合提交前过滤
This commit is contained in:
@@ -13274,7 +13274,11 @@ impl Strategy for PlatformExprStrategy {
|
||||
.iter()
|
||||
.filter(|symbol| !Self::projected_position_is_flat(&projected, symbol))
|
||||
.count();
|
||||
let daily_target_count = selection_limit.saturating_sub(blocked_exit_slots);
|
||||
let daily_target_count = if self.config.redistribute_target_weights_after_exit {
|
||||
selection_limit
|
||||
} else {
|
||||
selection_limit.saturating_sub(blocked_exit_slots)
|
||||
};
|
||||
let daily_target_portfolio_scales = resolved_target_scales(
|
||||
&original_target_scales,
|
||||
&candidate_target_scales,
|
||||
@@ -13291,6 +13295,21 @@ impl Strategy for PlatformExprStrategy {
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let execution_stock = if self.uses_intraday_execution_quotes() {
|
||||
let execution_time = self.intraday_execution_start_time();
|
||||
if self
|
||||
.scheduled_quote_at_time(ctx, projection_date, symbol, Some(execution_time))
|
||||
.is_none()
|
||||
{
|
||||
selection_notes.push(format!(
|
||||
"daily_target_skipped symbol={symbol} reason=execution_quote_unavailable no_order=true"
|
||||
));
|
||||
continue;
|
||||
}
|
||||
self.stock_state_at_time(ctx, projection_date, symbol, Some(execution_time))?
|
||||
} else {
|
||||
self.stock_state(ctx, projection_date, symbol)?
|
||||
};
|
||||
let target_value = target_value_for_scale(
|
||||
strategy_visible_total_value,
|
||||
trading_ratio,
|
||||
@@ -13305,6 +13324,20 @@ impl Strategy for PlatformExprStrategy {
|
||||
.position(&symbol)
|
||||
.map(|position| position.quantity)
|
||||
.unwrap_or(0);
|
||||
if before_qty == 0
|
||||
&& !defer_execution_risk
|
||||
&& let Some(reason) = self.buy_rejection_reason(
|
||||
ctx,
|
||||
execution_date,
|
||||
symbol,
|
||||
execution_stock.as_ref(),
|
||||
)?
|
||||
{
|
||||
selection_notes.push(format!(
|
||||
"daily_target_skipped symbol={symbol} reason={reason} no_order=true"
|
||||
));
|
||||
continue;
|
||||
}
|
||||
if before_qty > 0 {
|
||||
self.project_target_value(
|
||||
ctx,
|
||||
|
||||
Reference in New Issue
Block a user