QuantJourney Backtester

QuantJourney Backtester

Share product feedback

Thank you.

Your note is now in the QuantJourney inbox.

Analysis Modules:
how the research packet is built

The analysis layer is documented per source file. Each page explains the purpose, data contract, main functions, where the module is used, how to extend it and what to watch before using it in a serious strategy review.

1. ReturnsPrices become aligned return and NAV matrices.
2. Portfolio mathRisk, rolling stats, exposure, attribution and PnL functions run on labeled DataFrames.
3. Stress evidenceCrisis periods, Monte Carlo and round trips add review context.
4. Metric configReport rows map to nested result paths and formatter types.
5. Packet outputMetrics, plots, JSON, PDF and audit artifacts share the same contract.

Module Pages

backtester/portfolio/calc/returns.py

Return Analytics

Builds the basic return and NAV contract used by the rest of the analysis layer: periodic returns, total return, annualized return and NAV reconstruction.

backtester/portfolio/calc/risk.py

Risk Analytics

Calculates volatility, drawdowns, VaR/CVaR, downside risk and risk-adjusted ratios from return matrices.

backtester/portfolio/calc/rolling_stats.py

Rolling Statistics

Computes rolling mean, volatility, Sharpe, max drawdown, beta, alpha, Calmar and correlation for date x instrument matrices.

backtester/portfolio/calc/metrics.py

Metrics Utilities

Small convenience metrics for benchmark-relative returns, information coefficient, correlation, persistence, market sensitivity and tail dependence.

backtester/portfolio/calc/exposures.py

Exposure Analytics

Converts units and prices into market value exposures, long/short exposure, turnover and participation proxies.

backtester/portfolio/calc/attribution.py

Attribution Analytics

Runs factor OLS, extracts factor alpha and converts factor exposures into attributed return contributions.

backtester/portfolio/calc/montecarlo.py

Monte Carlo Simulation

Runs block-bootstrap Monte Carlo on return series to create NAV path distributions, drawdown distributions and probability queries.

backtester/portfolio/calc/round_trips.py

Round-Trip Analyzer

Canonical FIFO trade matching engine for round-trip PnL, holding periods, turnover, trade win/loss statistics and consistency checks.

backtester/portfolio/calc/pnl_multi_asset.py

Multi-Asset PnL

Computes asset-class-aware PnL, margin, notional exposure, returns and NAV for equities, futures, FX and crypto.

backtester/portfolio/crisis_analysis.py

Crisis Analysis

Loads named crisis and regime windows from JSON and computes strategy behavior inside each historical period.

backtester/metrics/configs/portfolio_perf.py

Portfolio Performance Config

Defines the report metric contract: visible section names, visible row names, nested result paths and formatter types.

Module Map

This table is the quick routing layer: choose the file by the question you are trying to answer.

Module Primary question it answers
returns.py Most downstream analytics assume a clean dates x instruments return matrix. This module defines that first contract so risk, rolling statistics, plots and reports are working from the same return basis.
risk.py A backtest is not reviewable from CAGR alone. This module turns the same return matrix into drawdown depth, tail loss, efficiency and pain metrics that can be shown in a report or compared across strategies.
rolling_stats.py Point-in-time metrics can hide regime decay. Rolling statistics show whether the strategy behavior is stable, deteriorating or concentrated in a short window.
metrics.py This is the glue layer for quick diagnostics that do not justify a full dedicated engine but are useful in report packets and research notebooks.
exposures.py Exposure explains what produced the return path. It is the bridge between target weights, realized positions and operational review: gross exposure, turnover and liquidity participation.
attribution.py A strategy can look good because of hidden beta, sector concentration or common factor exposure. Attribution separates the strategy story from the factor story.
montecarlo.py A single realized path is only one sample. Monte Carlo asks how fragile the outcome is under resampled return ordering and preserves some autocorrelation through block bootstrap.
round_trips.py Trade analytics become unreliable when each metric reconstructs trades differently. This module makes FIFO matching the single source of truth for blotter-level evidence.
pnl_multi_asset.py Mixed portfolios cannot treat every unit as a stock share. Futures multipliers, FX lot sizes, margin and inverse contracts change PnL and risk accounting.
crisis_analysis.py A strategy can have a good full-period Sharpe and still fail in exactly the periods that matter to a PM or allocator. Crisis analysis turns those periods into a first-class table.
portfolio_perf.py The report should not hard-code calculation paths in presentation code. This config is the map from calculation output to institutional report tables.