Align jq microcap execution with intraday snapshots

This commit is contained in:
boris
2026-04-20 12:13:59 +08:00
parent 0e2c25e4c4
commit 0fe681ff5f
10 changed files with 761 additions and 94 deletions

View File

@@ -17,7 +17,10 @@ impl Strategy for BuyThenHoldStrategy {
"buy-then-hold"
}
fn on_day(&mut self, ctx: &StrategyContext<'_>) -> Result<StrategyDecision, fidc_core::BacktestError> {
fn on_day(
&mut self,
ctx: &StrategyContext<'_>,
) -> Result<StrategyDecision, fidc_core::BacktestError> {
if ctx.decision_date == d(2025, 1, 2) && ctx.portfolio.position("000001.SZ").is_none() {
return Ok(StrategyDecision {
rebalance: false,
@@ -238,12 +241,17 @@ fn engine_settles_delisted_position_before_missing_market_snapshot_breaks_run()
let result = engine.run().expect("backtest succeeds");
assert_eq!(result.fills.len(), 2);
assert!(result
.fills
.iter()
.any(|fill| fill.reason.contains("delisted_cash_settlement") && fill.symbol == "000001.SZ"));
assert!(result
.holdings_summary
.iter()
.all(|holding| holding.symbol != "000001.SZ"));
assert!(
result
.fills
.iter()
.any(|fill| fill.reason.contains("delisted_cash_settlement")
&& fill.symbol == "000001.SZ")
);
assert!(
result
.holdings_summary
.iter()
.all(|holding| holding.symbol != "000001.SZ")
);
}