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

@@ -116,7 +116,10 @@ where
self.run_with_progress(|_| {})
}
pub fn run_with_progress<F>(&mut self, mut on_progress: F) -> Result<BacktestResult, BacktestError>
pub fn run_with_progress<F>(
&mut self,
mut on_progress: F,
) -> Result<BacktestResult, BacktestError>
where
F: FnMut(&BacktestDayProgress),
{
@@ -287,7 +290,9 @@ where
) -> BrokerExecutionReport {
result.order_events.extend(report.order_events.clone());
result.fills.extend(report.fill_events.clone());
result.position_events.extend(report.position_events.clone());
result
.position_events
.extend(report.position_events.clone());
result.account_events.extend(report.account_events.clone());
report
}
@@ -338,7 +343,11 @@ where
});
format!(
"cash_dividend_receivable {} share_cash={:.6} quantity={} payable_date={} cash={:.2}",
action.symbol, action.share_cash, quantity_after, payable_date, cash_delta
action.symbol,
action.share_cash,
quantity_after,
payable_date,
cash_delta
)
};
notes.push(note.clone());
@@ -457,7 +466,10 @@ where
let settlement_price = self
.data
.price_on_or_before(effective_delisted_at, &symbol, PriceField::Close)
.or_else(|| self.data.price_on_or_before(date, &symbol, PriceField::Close))
.or_else(|| {
self.data
.price_on_or_before(date, &symbol, PriceField::Close)
})
.filter(|price| price.is_finite() && *price > 0.0)
.unwrap_or(fallback_reference_price);
if !settlement_price.is_finite() || settlement_price <= 0.0 {