Insight Lifecycle
AQE tracks insights through a state machine that includes:
NewExecutedFilledClosedCancelledRejected
Typical paths look like:
New -> Executed -> Filled -> ClosedNew -> RejectedExecuted -> CancelledFilled -> Closed
Expiry, pipe failures, broker rejections, and trade updates all feed into those transitions.
Time-To-Live Fields
Section titled “Time-To-Live Fields”AQE supports two important lifecycle controls:
period_unfilledapplies while the insight is stillNeworExecuted. Expired insights are rejected or cancellation is requested, depending on state.period_till_tpapplies once the insight isFilled. Expiry can trigger a close request.
Those checks are enforced by the runtime, not by the UI.
State History
Section titled “State History”Every significant change can be recorded into state_history, including:
- state transitions
- submission
- broker acceptance
- fills
- partial closes
- cancellation requests
- rejections
- expiry handling
That history is what makes the shared inspector in AQS and Backtest Results useful for review.
Adding A Custom History Message
Section titled “Adding A Custom History Message”Use state_log(...) when you want to attach a review note to an insight without changing its lifecycle state. The strategy hook receives insights by shared reference, so add these messages from a pipe or another runtime path that has &mut Insight.
use aq_engine::core::insight::{types::InsightState, Insight};use aq_engine::core::pipeline::{InsightPipe, InsightPipeBuilder, InsightPipeResult};use aq_engine::core::strategy::StrategyContext;
pub struct ReviewNotePipe;
impl InsightPipe for ReviewNotePipe { fn version(&self) -> &str { "1.0" }
fn run(&mut self, _ctx: &mut dyn StrategyContext, insight: &mut Insight) -> InsightPipeResult { insight.state_log(Some("Risk check passed".to_string()));
InsightPipeResult::new( true, true, Some("Review note added to insight history".to_string()), self.name().to_string(), ) }}Register the pipe on the state where you want the note to be added:
ctx.add_pipe( InsightPipeBuilder::new(Box::new(ReviewNotePipe)) .target_state(InsightState::Filled) .build(),);state_log(...) keeps the current state, updates updated_at, and appends the supplied message to state_history. If you pass None, AQE records "State log entry".
Persistence
Section titled “Persistence”Insight snapshots include execution fields such as filled_price, close_price, broker_realized_pnl, commission, and swap. Live runs sync those snapshots to AQS Cloud, and backtests persist them to the local result database.
We use essential cookies and storage for sign-in, account security, colour theme preferences, this notice, and required PostHog internal usage, session quality, and reliability metrics. We do not use advertising cookies.
