修正退市整理期交易状态判定
This commit is contained in:
@@ -199,7 +199,7 @@ impl ChinaAShareRiskControl {
|
|||||||
let terminal_status = matches!(
|
let terminal_status = matches!(
|
||||||
status.as_str(),
|
status.as_str(),
|
||||||
"inactive" | "delisted" | "terminated" | "expired"
|
"inactive" | "delisted" | "terminated" | "expired"
|
||||||
) || status.contains("delist");
|
);
|
||||||
if terminal_status && instrument.delisted_at.is_none() {
|
if terminal_status && instrument.delisted_at.is_none() {
|
||||||
return Some("inactive_or_delisted");
|
return Some("inactive_or_delisted");
|
||||||
}
|
}
|
||||||
@@ -765,6 +765,45 @@ mod tests {
|
|||||||
NaiveDate::from_ymd_opt(year, month, day).expect("valid date")
|
NaiveDate::from_ymd_opt(year, month, day).expect("valid date")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn instrument(status: &str, delisted_at: Option<NaiveDate>) -> Instrument {
|
||||||
|
Instrument {
|
||||||
|
symbol: "002898.SZ".to_string(),
|
||||||
|
name: "赛隆退".to_string(),
|
||||||
|
board: "SZ".to_string(),
|
||||||
|
round_lot: 100,
|
||||||
|
listed_at: Some(d(2017, 9, 12)),
|
||||||
|
delisted_at,
|
||||||
|
status: status.to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn delisting_period_status_is_not_terminal_without_delisted_date() {
|
||||||
|
let date = d(2025, 3, 20);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
ChinaAShareRiskControl::instrument_rejection_reason(
|
||||||
|
Some(&instrument("delisting", None)),
|
||||||
|
date,
|
||||||
|
),
|
||||||
|
None
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
ChinaAShareRiskControl::instrument_rejection_reason(
|
||||||
|
Some(&instrument("delisted", None)),
|
||||||
|
date,
|
||||||
|
),
|
||||||
|
Some("inactive_or_delisted")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
ChinaAShareRiskControl::instrument_rejection_reason(
|
||||||
|
Some(&instrument("delisting", Some(d(2026, 7, 20)))),
|
||||||
|
d(2026, 7, 20),
|
||||||
|
),
|
||||||
|
Some("inactive_or_delisted")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn candidate(date: NaiveDate) -> CandidateEligibility {
|
fn candidate(date: NaiveDate) -> CandidateEligibility {
|
||||||
CandidateEligibility {
|
CandidateEligibility {
|
||||||
date,
|
date,
|
||||||
|
|||||||
Reference in New Issue
Block a user