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