限制盘后固定价格撮合生效日期

This commit is contained in:
boris
2026-08-27 19:20:37 +08:00
parent b6f4b05844
commit dd08358f1c
+13
View File
@@ -26,6 +26,9 @@ use crate::strategy::{
TargetPortfolioOrderPricing,
};
pub const POST_CLOSE_FIXED_PRICE_EFFECTIVE_DATE: NaiveDate =
NaiveDate::from_ymd_opt(2026, 7, 6).expect("valid post-close effective date");
#[derive(Debug, Error)]
pub enum BacktestError {
#[error(transparent)]
@@ -1970,6 +1973,16 @@ where
})
.filter(|date| self.config.end_date.map(|end| *date <= end).unwrap_or(true))
.collect::<Vec<_>>();
if self.broker.matching_type() == MatchingType::PostCloseFixedPrice
&& calendar_dates
.first()
.is_some_and(|date| *date < POST_CLOSE_FIXED_PRICE_EFFECTIVE_DATE)
{
return Err(BacktestError::Execution(format!(
"post_close_fixed_price is unavailable before {}",
POST_CLOSE_FIXED_PRICE_EFFECTIVE_DATE
)));
}
let has_decision_inputs = |date: NaiveDate| {
!self.data.factor_snapshot_rows_on(date).is_empty()
&& !self.data.candidate_snapshot_rows_on(date).is_empty()