Skip to content

Strategy Lifecycle

At the centre of AQE is the strategy lifecycle:

  • on_start
  • universe
  • init
  • on_bar
  • generate_insights
  • insight_pipeline
  • on_teardown
aq-engine/src/core/strategy/traits.rs
pub trait Strategy {
fn name(&self) -> &str {
"Base Strategy"
}
fn on_start(&mut self, ctx: &mut dyn StrategyContext);
fn init(&mut self, ctx: &mut dyn StrategyContext, asset: &Asset);
fn universe(&self, ctx: &mut dyn StrategyContext) -> HashSet<String>;
fn on_bar(&mut self, ctx: &mut dyn StrategyContext, symbol: &str, bar: &BarData);
fn generate_insights(&mut self, ctx: &mut dyn StrategyContext, symbol: &str);
fn insight_pipeline(&mut self, ctx: &mut dyn StrategyContext, insight: &Insight);
fn on_teardown(&mut self, ctx: &mut dyn StrategyContext);
}

Use on_start to register shared runtime setup:

  • indicators
  • alphas
  • pipes
  • risk settings
  • warm-up bars

universe() returns the symbols the strategy trades. AQE uses those symbols to load Asset metadata from the selected data/broker stack.

init() runs once per asset after universe loading. Use it for per-asset initialization such as per-symbol variables, symbol-specific indicator state, or asset-aware setup.

on_bar() is called each time a new bar arrives for a symbol. This is where you update strategy-level state from the latest market data.

After on_bar(), AQE calls generate_insights(). This is where you create new insights and add them to the runtime.

After bars are processed, AQE runs the insight pipeline. Pipes can size, validate, submit, reject, cancel, or close insights based on their current state.

Use on_teardown() for final cleanup and summaries.

For reusable startup, initialization, teardown, and universe-selection modules, see Lifecycle Components.