修复Platform选股阶段风控语义
This commit is contained in:
@@ -5947,21 +5947,15 @@ impl PlatformExprStrategy {
|
||||
let Some(market) = ctx.data.market(date, &factor.symbol) else {
|
||||
continue;
|
||||
};
|
||||
if !ctx.is_lagged_execution() {
|
||||
if let Some(reason) = self.selection_risk_rejection_reason(
|
||||
ctx,
|
||||
date,
|
||||
&factor.symbol,
|
||||
candidate,
|
||||
market,
|
||||
) {
|
||||
if let Some(reason) =
|
||||
self.selection_risk_rejection_reason(ctx, date, &factor.symbol, candidate, market)
|
||||
{
|
||||
if !(defer_limit_state_selection_risk
|
||||
&& matches!(reason, "upper_limit" | "lower_limit"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !self.stock_passes_universe_exclude(candidate, market) {
|
||||
continue;
|
||||
}
|
||||
@@ -5991,9 +5985,6 @@ impl PlatformExprStrategy {
|
||||
date: NaiveDate,
|
||||
factor_date: NaiveDate,
|
||||
) -> Vec<FidcRiskDecisionAudit> {
|
||||
if ctx.is_lagged_execution() {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut decisions = Vec::new();
|
||||
for factor in ctx.data.factor_snapshots_on(factor_date) {
|
||||
if ctx.has_dynamic_universe() && !ctx.dynamic_universe_contains(&factor.symbol) {
|
||||
@@ -14636,7 +14627,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn platform_next_open_selection_ignores_decision_day_static_risk_state() {
|
||||
fn platform_next_open_selection_applies_decision_day_static_risk_state() {
|
||||
let factor_date = d(2023, 11, 10);
|
||||
let decision_date = d(2023, 11, 13);
|
||||
let execution_date = d(2023, 11, 14);
|
||||
@@ -14805,7 +14796,7 @@ mod tests {
|
||||
decision
|
||||
.diagnostics
|
||||
.iter()
|
||||
.any(|item| item == "selected_symbols=600462.SH"),
|
||||
.any(|item| item == "selected_symbols="),
|
||||
"{:?}",
|
||||
decision.diagnostics
|
||||
);
|
||||
@@ -14813,20 +14804,20 @@ mod tests {
|
||||
decision
|
||||
.diagnostics
|
||||
.iter()
|
||||
.all(|item| !item.contains("600462.SH rejected by")),
|
||||
.any(|item| item.contains("risk_decisions selection_total=1 by_rule=paused:1")),
|
||||
"{:?}",
|
||||
decision.diagnostics
|
||||
);
|
||||
assert!(
|
||||
decision.order_intents.iter().any(|intent| match intent {
|
||||
OrderIntent::Shares {
|
||||
symbol, quantity, ..
|
||||
} => symbol == candidate_symbol && *quantity > 0,
|
||||
OrderIntent::Value { symbol, value, .. } => {
|
||||
symbol == candidate_symbol && *value > 0.0
|
||||
}
|
||||
_ => false,
|
||||
}),
|
||||
decision.order_intents.iter().all(|intent| !matches!(
|
||||
intent,
|
||||
OrderIntent::Shares { symbol, quantity, .. }
|
||||
if symbol == candidate_symbol && *quantity > 0
|
||||
) && !matches!(
|
||||
intent,
|
||||
OrderIntent::Value { symbol, value, .. }
|
||||
if symbol == candidate_symbol && *value > 0.0
|
||||
)),
|
||||
"{:?}",
|
||||
decision.order_intents
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user