Execute open auction strategy decisions

This commit is contained in:
boris
2026-04-23 00:41:32 -07:00
parent f0eec05b88
commit c27901306d
3 changed files with 164 additions and 6 deletions

View File

@@ -203,7 +203,13 @@ where
portfolio: &portfolio,
};
self.strategy.before_trading(&daily_context)?;
self.strategy.open_auction(&daily_context)?;
let auction_decision = self.strategy.open_auction(&daily_context)?;
let mut report = self.broker.execute(
execution_date,
&mut portfolio,
&self.data,
&auction_decision,
)?;
let decision = decision_slot
.map(|(decision_idx, decision_date)| {
@@ -218,9 +224,16 @@ where
.transpose()?
.unwrap_or_default();
let report =
let intraday_report =
self.broker
.execute(execution_date, &mut portfolio, &self.data, &decision)?;
report.order_events.extend(intraday_report.order_events);
report.fill_events.extend(intraday_report.fill_events);
report
.position_events
.extend(intraday_report.position_events);
report.account_events.extend(intraday_report.account_events);
report.diagnostics.extend(intraday_report.diagnostics);
let daily_fill_count = report.fill_events.len();
let day_orders = report.order_events.clone();
let day_fills = report.fill_events.clone();

View File

@@ -18,8 +18,11 @@ pub trait Strategy {
fn before_trading(&mut self, _ctx: &StrategyContext<'_>) -> Result<(), BacktestError> {
Ok(())
}
fn open_auction(&mut self, _ctx: &StrategyContext<'_>) -> Result<(), BacktestError> {
Ok(())
fn open_auction(
&mut self,
_ctx: &StrategyContext<'_>,
) -> Result<StrategyDecision, BacktestError> {
Ok(StrategyDecision::default())
}
fn on_day(&mut self, ctx: &StrategyContext<'_>) -> Result<StrategyDecision, BacktestError>;
fn after_trading(&mut self, _ctx: &StrategyContext<'_>) -> Result<(), BacktestError> {