Backtest And Live Runs
Selecting A Broker And Datafeed
Section titled “Selecting A Broker And Datafeed”AQE exposes execution brokers and market-data providers through UnifiedBroker.
Common combinations are:
PaperBroker+YahooFinanceDataFeedfor local historical backtests.PaperBroker+Mt5DataFeedwhen you want MT5 candles with simulated backtest execution.Mt5Broker+Mt5DataFeedfor live MetaTrader 5 execution.
let execution = PaperBroker::new(AccountType::Paper, 100_000.0, 1);let data = YahooFinanceDataFeed::new();let broker = UnifiedBroker::new_backtest(execution, data);For broker-specific setup, see Brokers & Datafeeds.
Running In Backtest Mode
Section titled “Running In Backtest Mode”The backtest runner follows the current StrategyState::run_backtest implementation:
// 1. strategy.on_start(ctx)// 2. load_universe() -> strategy.universe() -> broker.get_ticker_info()// 3. alpha.start() per alpha// 4. load_init() -> OnInit lifecycle logic -> strategy.init per asset// 5. alpha.init(asset) per alpha per asset// 6. broker.load_backtest_data()// 7. loop: broker step -> on_bar() -> optional insight generation -> run_insight_pipeline()// 8. strategy.on_teardown(ctx)// 9. return BacktestResultsGenerated runs save artifacts to disk under:
backtests/<run_id>/backtest.db
AQE writes the SQLite artifact with trade logs, round trips, account history, insights, and bars. You can inspect those results in AlgoQuant Studio through Backtest Results, or with any SQLite reader.
Running Live
Section titled “Running Live”Live mode uses the same strategy/runtime structure but subscribes to live data and trade updates.
You can run AQE live:
- with AQS, by passing auth and enabling live sync
- without AQS, by running
run_live(None)
if let Err(e) = state.run_live(auth).await { eprintln!("Live execution failed: {:?}", e); std::process::exit(1);}When auth is provided, AQE writes live state into AQS-scoped tables such as:
insightsstrategy_accountsstrategy_equity_pointsstrategy_live_metricsstrategy_events
When auth is omitted, AQE can still run live locally without synchronising into AQS.
Terminal UI
Section titled “Terminal UI”When AQE is compiled with the runtime and tui features and the process is attached to an interactive terminal, backtest and live runs open a Ratatui interface automatically. The TUI mirrors metrics, active insights, strategy variables, watched variable paths, AQS sync status, and runtime events.
Use --no-tui when you want the plain console log stream:
cargo run --features runtime,tui --release -- --no-tuiRead Terminal UI for the panel layout, controls, and live-run shutdown behaviour.
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.
