Add daily strategy lifecycle hooks

This commit is contained in:
boris
2026-04-22 22:15:55 -07:00
parent 32e29fdf9a
commit 34e16520fa
3 changed files with 263 additions and 3 deletions

View File

@@ -15,7 +15,16 @@ use crate::universe::{DynamicMarketCapBandSelector, SelectionContext, UniverseSe
pub trait Strategy {
fn name(&self) -> &str;
fn before_trading(&mut self, _ctx: &StrategyContext<'_>) -> Result<(), BacktestError> {
Ok(())
}
fn on_day(&mut self, ctx: &StrategyContext<'_>) -> Result<StrategyDecision, BacktestError>;
fn after_trading(&mut self, _ctx: &StrategyContext<'_>) -> Result<(), BacktestError> {
Ok(())
}
fn on_settlement(&mut self, _ctx: &StrategyContext<'_>) -> Result<(), BacktestError> {
Ok(())
}
}
pub struct StrategyContext<'a> {