Execute open auction strategy decisions
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user