统一FIDC卖出allow_sell风控

This commit is contained in:
boris
2026-07-04 17:01:02 +08:00
parent 487e1a38aa
commit 143a021067
2 changed files with 20 additions and 10 deletions
+19 -6
View File
@@ -506,10 +506,9 @@ impl ChinaAShareRiskControl {
if config.static_rules.reject_paused_sell && (market.paused || candidate.is_paused) {
return Some("paused");
}
// `allow_sell` is derived from the daily candidate snapshot and may
// reflect an open/close fallback rather than the actual execution price.
// A sell order must be blocked by the execution price lower-limit check
// below, while suspension and delisting are handled above.
if config.static_rules.respect_allow_buy_sell && !candidate.allow_sell {
return Some("sell_disabled");
}
if config.static_rules.reject_lower_limit_sell
&& market.is_at_lower_limit_price(check_price)
{
@@ -809,7 +808,7 @@ mod tests {
}
#[test]
fn sell_rejection_uses_execution_price_not_stale_allow_sell() {
fn sell_rejection_respects_allow_sell_policy_on_execution_day() {
let prev_date = d(2024, 4, 16);
let date = d(2024, 4, 17);
let candidate = candidate(date);
@@ -825,7 +824,21 @@ mod tests {
6.27,
);
assert_eq!(reason, None);
assert_eq!(reason, Some("sell_disabled"));
let mut relaxed = FidcRiskControlConfig::default();
relaxed.static_rules.respect_allow_buy_sell = false;
let relaxed_reason = ChinaAShareRiskControl::sell_rejection_reason_with_config(
date,
&candidate,
&market,
None,
Some(&position),
6.27,
&relaxed,
);
assert_eq!(relaxed_reason, None);
}
#[test]