让实际换股持仓继承原策略保护期限

This commit is contained in:
boris
2026-09-14 23:38:43 +08:00
parent ad76bdb6ae
commit ba4b77fd74
8 changed files with 370 additions and 44 deletions
+16 -1
View File
@@ -120,10 +120,25 @@ impl AutomaticTradeProtection {
execution_date: NaiveDate,
evidence: &HoldingLifecycleEvidence,
calendar: &TradingCalendar,
) -> Result<AutomaticTradePermission, String> {
self.evaluate_with_predecessors(symbol, execution_date, evidence, calendar, std::iter::empty())
}
/// Only accept predecessors from validated, actually applied holding
/// conversions. Catalog aliases or requested strategy symbols are not
/// evidence that a configured lock covers another security.
pub fn evaluate_with_predecessors<'a>(
&self,
symbol: &str,
execution_date: NaiveDate,
evidence: &HoldingLifecycleEvidence,
calendar: &TradingCalendar,
verified_predecessors: impl IntoIterator<Item = &'a str>,
) -> Result<AutomaticTradePermission, String> {
self.validate()?;
let predecessors = verified_predecessors.into_iter().collect::<std::collections::BTreeSet<_>>();
if self.locks.iter().any(|lock| {
lock.symbol == symbol
(lock.symbol == symbol || predecessors.contains(lock.symbol.as_str()))
&& lock.start_date <= execution_date
&& lock.end_date.is_none_or(|end| execution_date <= end)
}) {