修正调仓持仓报价预加载语义

This commit is contained in:
boris
2026-06-15 20:29:14 +08:00
parent 725f1845d9
commit baeda3773d
3 changed files with 136 additions and 3 deletions
@@ -52,7 +52,7 @@ impl Strategy for DecisionQuoteReader {
.data
.execution_quotes_on(ctx.execution_date, "000001.SZ")
.iter()
.any(|quote| quote.timestamp.time() == t(10, 40, 0) && quote.last_price == 11.0);
.any(|quote| quote.timestamp.time() == t(10, 39, 59) && quote.last_price == 11.0);
assert!(
quote_loaded_before_decision,
"engine must load declared decision quote before strategy.on_day"
@@ -199,6 +199,10 @@ fn engine_preloads_declared_decision_quotes_for_current_positions() {
};
let mut engine = BacktestEngine::new(data, DecisionQuoteReader::default(), broker, config)
.with_execution_quote_loader(move |request| {
assert_eq!(
request.end_time, None,
"decision quote preload must request latest quote at or before start_time"
);
Ok(request
.symbols
.into_iter()
@@ -207,7 +211,7 @@ fn engine_preloads_declared_decision_quotes_for_current_positions() {
symbol,
timestamp: request
.date
.and_time(request.start_time.unwrap_or(t(10, 40, 0))),
.and_time(t(10, 39, 59)),
last_price: if request.date == second { 11.0 } else { 10.0 },
bid1: if request.date == second { 11.0 } else { 10.0 },
ask1: if request.date == second { 11.0 } else { 10.0 },