QuantJourney Backtester

QuantJourney Backtester

Share product feedback

✓

Thank you.

Your note is now in the QuantJourney inbox.

docs/engine/architecture.mdx

Architecture

How QuantJourney Backtester is organized across data, strategy hooks, execution, portfolio state and reporting.

QuantJourney Backtester is organized as a layered research system. Strategy code expresses intent; the engine owns data alignment, timing, accounting, execution assumptions, validation and report artifacts.

Technology

End-to-End Backtest Engine Stack

From strategy hooks to auditable portfolio evidence.
Strategy Surface
Strategy subclass _compute_signals(), _compute_weights(), _compute_orders(...)
Data & Features
Universe + InstrumentData prices, OHLCV, indicators, adjusted close, strategy feature frames
Backtest Engine
Backtester core lifecycle, data preparation, mode dispatch, run orchestration
Weight mode pipeline signals -> target weights -> risk overlays -> rebalance policy
Order mode pipeline orders -> pending book -> triggers -> slippage -> commission -> fills
Portfolio state cash, positions, weights, NAV, returns, turnover, blotter
Analytics layer metrics, drawdowns, exposures, attribution, crisis and scenario analysis
Reports and archive plots, PDF, factsheet, metadata, reproducibility artifacts
Validation
Walk-forward + optimization folds, pre-OOS purge, Optuna/grid search, DSR, rank stability, OOS aggregation
Delivery
SDK + hosted runner local-first engine with optional hosted Backtester API workflows

How To Read The Engine

Weight modeStrategy returns target exposures. Risk and rebalance logic convert them into actual weights, positions, NAV and costs.
Order modeStrategy submits orders. FillEngine owns pending orders, fill assumptions, commissions, cash and position mutation.
ReportsBoth paths converge into PortfolioData, then metrics, plots, PDFs, blotter and archive metadata.

Backtest Engine Module Map

Use this map when you want to know which directory owns which behavior. The top of each card is the responsibility; the file list underneath is where to start reading.

Public strategy surface

What a strategy author touches first.

backtester/core.py Backtester lifecycle, run_strategy(), mode dispatch and strategy hook orchestration.
backtester/__init__.py Public exports for Backtester, order types, risk models and rebalance primitives.
strategies/ Runnable examples for weight mode, order mode, rebalance policies and validation workflows.

Data and feature layer

How raw prices become aligned feature frames.

backtester/universe.py Universe helpers and instrument set definitions.
backtester/portfolio/instr_data.py InstrumentData container for OHLCV, adjusted close, indicators and strategy features.
backtester/portfolio/instr_calc.py Instrument-level calculations used before signals, weights or orders read data.
backtester/portfolio/config.py Portfolio and data-processing configuration surface.

Weight-mode portfolio engine

Target weights become realized portfolio state.

backtester/portfolio/rebalance.py RebalancePolicy and RebalanceEngine for calendar, drift, signal and risk-triggered rebalances.
backtester/portfolio/portf_data.py PortfolioData state: returns, NAV, weights, positions, turnover and artifacts.
backtester/portfolio/portf_calc.py Portfolio-level performance and accounting calculations.
backtester/portfolio/weight_cost.py Turnover and transaction-cost handling for weight-mode portfolios.
backtester/portfolio/schemas.py Typed portfolio result schemas and validation contracts.

Order-mode execution engine

Discrete orders become fills, cash and position mutations.

backtester/execution/order_types.py Order, OrderType, side, time-in-force, bracket and OCO data structures.
backtester/execution/fill_engine.py Pending order book, trigger checks, fill pricing, child orders and sibling cancellation.
backtester/execution/slippage.py Fixed bps, market impact and execution price adjustment models.
backtester/execution/commission.py Per-fill commission schemes and minimum ticket costs.
backtester/execution/contract_spec.py Contract metadata for futures and multi-asset PnL handling.

Risk overlays

Weight transforms before portfolio accounting.

backtester/risk/base.py RiskModel interface and composition contract.
backtester/risk/position_limit.py Per-instrument exposure caps and clipping.
backtester/risk/vol_target.py Volatility targeting overlay.
backtester/risk/inverse_vol.py Inverse-volatility allocation.
backtester/risk/risk_parity.py Risk parity style allocation logic.

Analytics and reports

The run becomes evidence: metrics, plots, PDFs and archives.

backtester/engines/performance.py Main performance report engine and rich result assembly.
backtester/engines/plot_orchestrator.py Coordinates report plots from portfolio, strategy trace and analytics modules.
backtester/engines/pdf_creation.py PDF creation pipeline.
backtester/engines/factsheet_pdf.py Factsheet-style PDF output.
backtester/engines/archive.py Run archive, reproducibility metadata and persisted artifacts.
backtester/engines/blotter.py Order/fill/trade audit output.
backtester/metrics/configs/portfolio_perf.py Portfolio performance metric definitions and report configuration.

Validation and optimization

Out-of-sample checks around an already-defined engine run.

backtester/walkforward/engine.py WalkForwardEngine orchestration.
backtester/walkforward/config.py Fold, purge and validation settings.
backtester/walkforward/folds/ Rolling, expanding, anchored, CPCV and purge fold builders.
backtester/walkforward/optimization/ Grid and Optuna optimization helpers.
backtester/walkforward/statistics/ Aggregation, DSR, rolling rank stability and overfit diagnostics.

SDK, cloud and utilities

Hosted runner integration and supporting infrastructure.

backtester/sdk/client.py Client for hosted Backtester API workflows.
backtester/mixins/sdk_client.py Strategy mixin for SDK behavior.
backtester/mixins/reporting.py Reporting helper mixin used by strategy objects.
backtester/im_client.py Infrastructure messaging client.
backtester/utils/reproducibility.py Run metadata and reproducibility helpers.
backtester/utils/logger.py Package logging utilities.

Ownership Boundaries

Strategy code ownssignals, target weights, order rules, parameter choices and research intent.
Engine core ownsdata timing, mode dispatch, weight shift, state mutation, cash, positions, NAV and run lifecycle.
Execution ownspending order state, trigger checks, fill prices, slippage, commission, brackets and OCO cancellation.
Portfolio ownsactual weights, positions, returns, turnover, rebalance flags and portfolio-level analytics.
Reports ownperformance tables, plots, PDFs, archives, metadata and review-ready output.
Validation ownsfold construction, OOS aggregation, optimization summaries and overfit diagnostics.