Compare commits
1 Commits
main
...
7f60bfac1d
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f60bfac1d |
@@ -334,6 +334,9 @@ impl ChinaAShareRiskControl {
|
|||||||
{
|
{
|
||||||
return Some(reason);
|
return Some(reason);
|
||||||
}
|
}
|
||||||
|
if let Some(reason) = candidate_active_status_rejection(candidate, config, scope) {
|
||||||
|
return Some(reason);
|
||||||
|
}
|
||||||
let reject_paused = match scope {
|
let reject_paused = match scope {
|
||||||
RiskCheckScope::Selection => config.static_rules.reject_paused_selection,
|
RiskCheckScope::Selection => config.static_rules.reject_paused_selection,
|
||||||
RiskCheckScope::Buy => config.static_rules.reject_paused_buy,
|
RiskCheckScope::Buy => config.static_rules.reject_paused_buy,
|
||||||
@@ -543,6 +546,26 @@ fn symbol_is_bjse(symbol: &str) -> bool {
|
|||||||
normalized.ends_with(".BJ") || normalized.ends_with(".BSE") || normalized.ends_with(".BE")
|
normalized.ends_with(".BJ") || normalized.ends_with(".BSE") || normalized.ends_with(".BE")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn candidate_active_status_rejection(
|
||||||
|
candidate: &CandidateEligibility,
|
||||||
|
config: &FidcRiskControlConfig,
|
||||||
|
scope: RiskCheckScope,
|
||||||
|
) -> Option<&'static str> {
|
||||||
|
let enabled = match scope {
|
||||||
|
RiskCheckScope::Selection => config.static_rules.reject_inactive_selection,
|
||||||
|
RiskCheckScope::Buy => config.static_rules.reject_inactive_buy,
|
||||||
|
RiskCheckScope::Sell => config.static_rules.reject_inactive_sell,
|
||||||
|
};
|
||||||
|
if !enabled {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
match candidate.risk_level_code.as_deref().map(str::trim) {
|
||||||
|
Some("not_listed") => Some("not_listed"),
|
||||||
|
Some("inactive_or_delisted") => Some("inactive_or_delisted"),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn missing_risk_state_fields(code: &str) -> Vec<String> {
|
fn missing_risk_state_fields(code: &str) -> Vec<String> {
|
||||||
let Some((_, fields)) = code.split_once(':') else {
|
let Some((_, fields)) = code.split_once(':') else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
@@ -1007,6 +1030,40 @@ mod tests {
|
|||||||
assert_eq!(decision.reason, "kcb");
|
assert_eq!(decision.reason, "kcb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn explicit_candidate_inactive_status_is_not_treated_as_missing_risk_state() {
|
||||||
|
let date = d(2025, 1, 2);
|
||||||
|
let mut candidate = candidate(date);
|
||||||
|
candidate.allow_sell = true;
|
||||||
|
candidate.risk_level_code = Some("inactive_or_delisted".to_string());
|
||||||
|
let market = market(date, 6.27, 5.63);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
ChinaAShareRiskControl::selection_rejection_reason(date, &candidate, &market, None),
|
||||||
|
Some("inactive_or_delisted")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
ChinaAShareRiskControl::buy_rejection_reason(date, &candidate, &market, None, 6.27),
|
||||||
|
Some("inactive_or_delisted")
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut relaxed = FidcRiskControlConfig::default();
|
||||||
|
relaxed.static_rules.reject_inactive_selection = false;
|
||||||
|
relaxed.static_rules.reject_inactive_buy = false;
|
||||||
|
assert_eq!(
|
||||||
|
ChinaAShareRiskControl::selection_rejection_reason_with_config(
|
||||||
|
date, &candidate, &market, None, &relaxed
|
||||||
|
),
|
||||||
|
None
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
ChinaAShareRiskControl::buy_rejection_reason_with_config(
|
||||||
|
date, &candidate, &market, None, 6.27, &relaxed
|
||||||
|
),
|
||||||
|
None
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user