保留AiQuant盘中卖出价格风控语义

This commit is contained in:
boris
2026-07-04 17:02:55 +08:00
parent 143a021067
commit a8ffd36150
2 changed files with 12 additions and 3 deletions
+9 -2
View File
@@ -2295,7 +2295,10 @@ where
position: &crate::portfolio::Position, position: &crate::portfolio::Position,
algo_request: Option<&AlgoExecutionRequest>, algo_request: Option<&AlgoExecutionRequest>,
) -> RuleCheck { ) -> RuleCheck {
if self.risk_config.static_rules.respect_allow_buy_sell && !candidate.allow_sell { if self.risk_config.static_rules.respect_allow_buy_sell
&& !self.aiquant_execution_rules
&& !candidate.allow_sell
{
return RuleCheck::reject("sell_disabled"); return RuleCheck::reject("sell_disabled");
} }
let check_price = if self.aiquant_execution_rules { let check_price = if self.aiquant_execution_rules {
@@ -2310,6 +2313,10 @@ where
} else { } else {
ChinaAShareRiskControl::sell_check_price(snapshot, self.execution_price_field) ChinaAShareRiskControl::sell_check_price(snapshot, self.execution_price_field)
}; };
let mut risk_config = self.risk_config.clone();
if self.aiquant_execution_rules {
risk_config.static_rules.respect_allow_buy_sell = false;
}
if let Some(reason) = ChinaAShareRiskControl::sell_rejection_reason_with_config( if let Some(reason) = ChinaAShareRiskControl::sell_rejection_reason_with_config(
date, date,
candidate, candidate,
@@ -2317,7 +2324,7 @@ where
instrument, instrument,
Some(position), Some(position),
check_price, check_price,
&self.risk_config, &risk_config,
) { ) {
return RuleCheck::reject(reason); return RuleCheck::reject(reason);
} }
+3 -1
View File
@@ -845,7 +845,8 @@ mod tests {
fn sell_rejection_blocks_execution_price_at_lower_limit() { fn sell_rejection_blocks_execution_price_at_lower_limit() {
let prev_date = d(2024, 4, 16); let prev_date = d(2024, 4, 16);
let date = d(2024, 4, 17); let date = d(2024, 4, 17);
let candidate = candidate(date); let mut candidate = candidate(date);
candidate.allow_sell = true;
let market = market(date, 5.63, 5.63); let market = market(date, 5.63, 5.63);
let position = position(prev_date); let position = position(prev_date);
@@ -1081,6 +1082,7 @@ mod tests {
fn missing_risk_state_rejects_selection_and_buy_when_static_filters_enabled() { fn missing_risk_state_rejects_selection_and_buy_when_static_filters_enabled() {
let date = d(2025, 1, 2); let date = d(2025, 1, 2);
let mut candidate = candidate(date); let mut candidate = candidate(date);
candidate.allow_sell = true;
candidate.risk_level_code = Some("missing_risk_state:is_st,allow_buy".to_string()); candidate.risk_level_code = Some("missing_risk_state:is_st,allow_buy".to_string());
let market = market(date, 6.27, 5.63); let market = market(date, 6.27, 5.63);