QuantJourney Backtester

QuantJourney Backtester

Share product feedback

✓

Thank you.

Your note is now in the QuantJourney inbox.

O17 · example_orders_17_monthly_rotation_orders.py

O17 Monthly Rotation Orders

An event-driven monthly rotation executed with explicit orders. On the first bar of each new month, rank the universe by 6-month momentum, then sell names that dropped out of the top set and buy the new entrants at market.

What this example shows

This example shows how to build a daily-bar order-based order-mode example with signal-to-order conversion, fills, positions, cash accounting and run artifacts.

The goal is educational: to demonstrate the full workflow for universe definition, signal generation, order construction, fill simulation, cash and position accounting, diagnostics and reproducible reporting.

Full performance run. Full performance run on the published example setup. It shows the observed behavior of runnable research code; it is not presented as optimized alpha or an investment recommendation.

Run setup

The ordinary configuration used by the published run—kept visible here and in the Python source.

UniverseSPY · EFA · EEM · TLT · IEF · GLD · DBC · VNQ
Configured period2007-01-03 → 2026-01-01
BenchmarkSPY · SPDR S&P 500 ETF Trust
Initial capital$100,000
Data sourceyfinance
Engine / snapshot0.10.0 · 1d41c7aef90fbe1d
Order ModeMode
1dGranularity
8Instruments
42Published plots
passedRun status

Dashboard

Compact evidence view built from the same run packet: metrics, plots and run metadata.

8.62% CAGR
0.53 Sharpe
-28.23% Max DD
380.52% Total return
12.77% Volatility

Selected plot gallery

42 published PNG artifacts. Charts marked Pro are generated by the hosted platform report pack; the rest come from the open-source engine output.

O17 Monthly Rotation Orders Cumulative Returns
Cumulative Returns PNG
O17 Monthly Rotation Orders Portfolio Drawdown
Portfolio Drawdown PNG
O17 Monthly Rotation Orders Monthly Returns Heatmap
Monthly Returns Heatmap PNG
O17 Monthly Rotation Orders Annual Returns
Annual Returns PNG
O17 Monthly Rotation Orders Nav Composition
Nav Composition Pro PNG
O17 Monthly Rotation Orders Percentage Weights
Percentage Weights PNG
O17 Monthly Rotation Orders Crisis Summary
Crisis Summary Pro PNG
O17 Monthly Rotation Orders Correlation Heatmap
Correlation Heatmap PNG
O17 Monthly Rotation Orders Blotter Trade Pnl
Blotter Trade Pnl Pro PNG
O17 Monthly Rotation Orders Blotter Cumulative Pnl
Blotter Cumulative Pnl Pro PNG

Performance

O17 Monthly Rotation Orders Cumulative Log Returns
Cumulative Log Returns PNG
O17 Monthly Rotation Orders Relative Performance
Relative Performance Pro PNG

Risk and exposure

O17 Monthly Rotation Orders Asset Risk Contribution
Asset Risk Contribution Pro PNG

Crisis and regimes

O17 Monthly Rotation Orders Benchmark Regime Analysis
Benchmark Regime Analysis Pro PNG
O17 Monthly Rotation Orders Crisis Periods
Crisis Periods Pro PNG
O17 Monthly Rotation Orders Cumulative Returns With Regime
Cumulative Returns With Regime Pro PNG

Execution

O17 Monthly Rotation Orders Blotter Costs
Blotter Costs Pro PNG
O17 Monthly Rotation Orders Blotter Frequency
Blotter Frequency Pro PNG
O17 Monthly Rotation Orders Blotter Holding Periods
Blotter Holding Periods Pro PNG
O17 Monthly Rotation Orders Blotter Instrument Pnl
Blotter Instrument Pnl Pro PNG
O17 Monthly Rotation Orders Blotter Trade Size
Blotter Trade Size Pro PNG
O17 Monthly Rotation Orders Blotter Trade Timeline
Blotter Trade Timeline Pro PNG
O17 Monthly Rotation Orders Turnover Vs Performance
Turnover Vs Performance Pro PNG

Portfolio accounting

O17 Monthly Rotation Orders Composition
Composition PNG

Drawdown

O17 Monthly Rotation Orders Drawdown Recovery
Drawdown Recovery PNG
O17 Monthly Rotation Orders Portfolio Drawdown With Regime
Portfolio Drawdown With Regime Pro PNG
O17 Monthly Rotation Orders Time Underwater
Time Underwater PNG

Distribution and optimization

O17 Monthly Rotation Orders Efficient Frontier
Efficient Frontier Pro PNG
O17 Monthly Rotation Orders Expected Return Profile
Expected Return Profile Pro PNG
O17 Monthly Rotation Orders Omega Curve
Omega Curve Pro PNG
O17 Monthly Rotation Orders Return Quantiles
Return Quantiles PNG
O17 Monthly Rotation Orders Returns Distribution
Returns Distribution Pro PNG

Rolling diagnostics

O17 Monthly Rotation Orders Rolling Max Dd
Rolling Max Dd Pro PNG
O17 Monthly Rotation Orders Rolling Sharpe
Rolling Sharpe Pro PNG
O17 Monthly Rotation Orders Rolling Volatility
Rolling Volatility Pro PNG
O17 Monthly Rotation Orders Rolling Alpha
Rolling Alpha Pro PNG
O17 Monthly Rotation Orders Rolling Asset Correlations
Rolling Asset Correlations PNG
O17 Monthly Rotation Orders Rolling Beta
Rolling Beta Pro PNG
O17 Monthly Rotation Orders Rolling Sortino Ratio
Rolling Sortino Ratio PNG
O17 Monthly Rotation Orders Rolling Tail Risk
Rolling Tail Risk Pro PNG
O17 Monthly Rotation Orders Rolling Var Cvar
Rolling Var Cvar PNG

Simulation

O17 Monthly Rotation Orders Monte Carlo Simulation
Monte Carlo Simulation Pro PNG

Metrics

Parsed from performance_report.txt.

Executive Summary

Metric Value What it tells you
CAGR 8.62% Annualized compound growth rate across the full backtest period.
Net Profit $380,518 Dollar profit generated above the initial capital after the simulated run.
Sharpe Ratio 0.53 Excess return per unit of volatility using the configured risk-free rate.
Max Drawdown -28.23% Largest peak-to-trough portfolio decline in percentage terms.

Performance Breakdown

Metric Value What it tells you
MTD 1.72% Month-to-date return at the report date.
QTD 7.39% Quarter-to-date return at the report date.
YTD 32.76% Year-to-date return at the report date.
1Y 32.36% Trailing one-year return.
3Y (ann.) 17.69% Annualized return over the trailing three-year window.
5Y (ann.) 11.52% Annualized return over the trailing five-year window.
ITD 380.52% Inception-to-date total return.
Cumulative Return 380.52% Total compounded return over the full backtest period.
ATH Value 4.9384 Highest portfolio value reached when normalized to the initial portfolio base.
Drawdown from ATH -2.70% Current distance below the all-time high at the report date.

Risk-Adjusted Metrics

Metric Value What it tells you
Sharpe Ratio 0.53 Excess return divided by total volatility.
Smart Sharpe Ratio 0.53 Sharpe variant adjusted for serial correlation effects.
Sortino Ratio 0.73 Excess return divided by downside volatility only.
Smart Sortino Ratio 0.73 Sortino variant adjusted for serial correlation effects.
Calmar Ratio 0.31 Annualized return divided by absolute max drawdown.
Omega Ratio 1.13 Ratio of gains above a threshold to losses below it.
Information Ratio -0.15 Active return divided by tracking error versus the benchmark.

Benchmark Comparison

Metric Value What it tells you
Benchmark Name SPDR S&P 500 … Benchmark used for comparison, beta, active return and information ratio.
Benchmark MTD 0.08% Benchmark month-to-date return.
Benchmark QTD 2.67% Benchmark quarter-to-date return.
Benchmark YTD 17.72% Benchmark year-to-date return.
Benchmark 1Y 15.95% Benchmark trailing one-year return.
Benchmark 3Y (ann.) 22.82% Benchmark annualized trailing three-year return.
Benchmark 5Y (ann.) 14.72% Benchmark annualized trailing five-year return.
Benchmark ITD 586.07% Benchmark inception-to-date total return over the strategy sample.
Excess Return YTD 15.04% Strategy return minus benchmark return for the year-to-date window.
Active Return YTD (ann.) 15.19% Annualized active return for the year-to-date window.
Excess Return Full Period -205.55% Arithmetic difference of cumulative returns in percentage points — strategy minus benchmark over the whole sample.
Active Return Full Period (ann.) -2.06% Annualized active return across the full sample.

Risk Metrics

Metric Value What it tells you
Vol (Recent Window) 11.41% Annualized volatility over the most recent rolling window.
Vol (Rolling Window) 12.77% Annualized volatility over the configured rolling window.
Vol Recent Obs 30 Number of observations used for recent volatility.
Vol Rolling Obs 252 Number of observations in the rolling volatility window.
Peak Vol (95%) 20.29% High-end volatility estimate from the rolling distribution.
VaR (95%) CF Normal 1.43% One-period 95% Value-at-Risk under a normal approximation.
VaR (95%) Stress Vol 1.96% Stress-calibrated 95% Value-at-Risk estimate.
Expected Shortfall 2.70% Average loss conditional on being beyond the VaR threshold.
Stress Tail Obs 950
Tracking Error 19.01% Annualized volatility of active return versus the benchmark.
Max Drawdown -28.23% Worst percentage peak-to-trough decline.
Max Drawdown ($) -$87,488 Worst peak-to-trough decline translated into dollars for the configured capital.
Distribution Skewness -0.4709 Asymmetry of the return distribution.
Distribution Kurtosis 3.6928 Tail heaviness relative to a normal distribution.
Tail Risk Ratio 1.1378 Upside tail magnitude divided by downside tail magnitude.
Worst Loss Magnitude 6.35% Worst single-period loss in the report frequency.
5 Worst Days Avg Loss 5.16% Average return across the five worst days.

Market Dynamics

Metric Value What it tells you
CAPM Alpha (ann.) 4.43% Annualized return unexplained by benchmark beta in a CAPM-style regression.
Beta 0.28 Sensitivity to benchmark moves.
Up Capture 22.49% How much of benchmark upside the strategy captures in up markets.
Down Capture 64.84% How much of benchmark downside the strategy captures in down markets.
R-Squared 0.16 Share of strategy return variation explained by benchmark variation.
Correlation 0.40 Linear co-movement between strategy and benchmark returns.

Strat Characteristics

Metric Value What it tells you
Inception Date 2007-01-03 First date included in the performance track record.
Current Date 2025-12-31 Final report date for the sample.
Track Record 18Y 11M Length of the tested track record.
Strategy Type Momentum Rota… Strategy can be long or flat in cash rather than always invested or short.
Base Currency USD Currency used for capital, PnL and dollar metrics.
Long Exposure 110.28% Current or average long exposure depending on report configuration.
Gross Exposure 110.28% Total absolute exposure across long and short positions.
Position Count 3 Number of instruments in the active universe or current holdings.
Concentration 41.60% Largest or representative concentration measure in the portfolio.
Raw Concentration 34.20% Concentration before final clipping, accounting or reporting adjustments.
Effective Positions 8 Diversification estimate based on concentration rather than simple instrument count.

Exposure Path Checks

Metric Value What it tells you
Max Gross Exposure 114.93% Highest gross exposure reached during the run.
Avg Gross Exposure 100.60% Average absolute exposure across the backtest.
Max Long Exposure 114.93% Highest long-side exposure reached during the run.
Min Cash Sleeve -14.93% Lowest cash percentage observed in the simulated portfolio.
Max Cash Sleeve 100.00% Highest cash percentage observed in the simulated portfolio.
Cash Sleeve Nonnegative ✗ Sanity check that cash did not go below zero when it should not.
Finite Weights ✓ Sanity check that target weights are finite numbers.

Trading Analytics

Metric Value What it tells you
Win Rate (Trade) 52.15% Percentage of trades that were profitable.
Win Rate (Day) 52.80% Percentage of daily observations with positive return.
Win Rate (Month) 58.77% Percentage of positive months.
Profit Factor (Trade) 1.78 Gross winning trade PnL divided by gross losing trade PnL.
Recovery Factor 0.31 Net profit divided by maximum drawdown.
Expectancy $1,426.34 Average expected profit per trade.
Avg Gain/Loss Ratio (Trade) 1.63 Average winning trade size divided by average losing trade size.
Largest Win $38,173.23 Largest single winning trade.
Largest Loss -$19,168.64 Largest single losing trade.
Average Win $6,255.13 Mean profit across winning trades.
Average Loss -$3,835.81 Mean loss across losing trades.
Max Consecutive Win Days 13 Longest streak of positive daily returns.
Max Consecutive Loss Days 9 Longest streak of negative daily returns.
Total Trades 329 Total buy and sell trade events.
Buy Trades 166 Number of buy-side trade events.
Sell Trades 163 Number of sell-side trade events.
Total FIFO Lot RTs 163 Matched entry-exit trade cycles.
Long FIFO Lot RTs 163 Round trips for long positions.
Avg Lot Holding Period 117 days Average time a matched position remains open.
Median Lot Holding Period 63 days Median matched holding period.
Turnover (ann.) 280.42% Annualized trading activity relative to portfolio value.
Avg Trade Size $77,779 Average notional size of trade events.

Advanced Risk

Metric Value What it tells you
CVaR / Expected Shortfall (95%) 2.70% Average loss conditional on being beyond the VaR threshold.
Serenity Index 1.39 Return quality measure that penalizes drawdown severity and persistence.

Advanced Trading

Metric Value What it tells you
Gain-to-Pain Ratio 1.13 Total gains divided by total losses over the period.
Drawdown-Vol Adj. Return 0.09 Return adjusted by both drawdown and volatility pressure.
Win Streak Concentration 0.01 Measures whether gains are concentrated in short winning streaks.
Kelly Criterion (Daily Returns) 2.73% Theoretical capital fraction implied by win/loss profile.
Tail Ratio 1.14 Upper-tail return magnitude divided by lower-tail magnitude.

Operational Metrics

Metric Value What it tells you
Total Commission $2,427.77 Total simulated commission paid across all trade events.
Commission (% Vol) 0.01% Commission as a percentage of traded volume.
Total Volume $25,589,430 Total simulated notional traded.
Instruments 8 Number of instruments traded or evaluated.

Consistency Checks

Metric Value What it tells you
Trade/2x FIFO Lot RT 1.01 Compares trade count to twice the FIFO lot round-trip count.
Avg Trades / FIFO Lot RT 2.02 Average number of trade events per FIFO lot round trip.
Strict Lot-Match Check ✓ Boolean check that FIFO lot matching completed cleanly.
Volume Consistency 0.99 Internal consistency score for volume reconstruction.
Volume Consistent ✓ Boolean sanity check for volume accounting.
RT Position-Day Load 3.99 Round-trip position-day load used to reconcile holding-period and exposure behavior.
RT Granularity fifo_lot_level Round-trip matching level used for trade analytics.

Execution Context

Metric Value What it tells you
Backtester Version 0.10.0+privat… Version of the engine that generated the report.
Data Start 2007-01-03 First date available in the input data.
Data End 2026-01-01 Final date available in the input data.
Trading Days 4780 Number of trading-day observations in the dataset.
Reporting Frequency daily Frequency used for returns and report metrics.
Reporting Observations 4780 Number of observations used in the report calculations.
Reporting Periods/Year 252 Annualization factor used for daily metrics.
Initial Capital $100,000 Starting capital used for dollar PnL and trade sizing.
Risk-Free Rate 2.00% Risk-free rate used in excess-return calculations.
Slippage Model FixedBpsSlipp… Name of the slippage model used in the run.
Commission Model PerShareCommi… Name of the commission model used in the run.
Fill At open Configured fill timing convention for order-mode or execution assumptions.

Reproducibility

Metric Value What it tells you
Fingerprint 25284c930b732… Run fingerprint tying configuration and data context to this output.
Config Hash e95fdf97bf8c3… Hash of configuration choices used by the run.
Data Hash ccddb577d0481… Hash of input data used by the run.
Sanity Checks Passed ✓ Summary flag over the packet’s internal consistency checks: holding-period coverage, trade-to-round-trip lot matching, volume reconstruction and NAV reconciliation.

Interesting Times

Metric Value What it tells you
Crises Evaluated 18 Number of crisis windows that overlapped the strategy sample and were evaluated.
Crises Defined 20 Total crisis windows available in the library definition.
Avg Crisis Return -1.79% Average strategy return across evaluated crisis windows.
Worst Crisis 2022 Rate Sho… Crisis window with the worst strategy result.
Best Crisis EU Debt Crisis Crisis or recovery window with the best strategy result.
Crisis Hit Rate 44.44% Share of evaluated crisis windows with positive strategy return.

Artifacts

Stable links that can be referenced from GitHub README files or external docs.

Run log

Tail of the execution log for this packet.

Running strategy: example_orders_17_monthly_rotation_orders
File: <QJ_BACKTESTER_REPO>/strategies/example_orders_17_monthly_rotation_orders.py
Python: <QJ_BACKTESTER_REPO>/.venv/bin/python
Backtester: v0.10.0
Theme: quantjourney
Plot DPI: 300
Log Level: ERROR
Output: reports/canonical-suite-20260711


============================================================
  Strategy: ExampleOrders17_MonthlyRotationOrders
  Backtester: v0.10.0
  Period:   2007-01-03 → 2025-12-31
  Assets:   SPY, EFA, EEM, TLT, IEF, GLD, DBC, VNQ
────────────────────────────────────────────────────────────
  Initial NAV:  $    100,000.00
  Final NAV:    $    480,517.75
  Total Return:        380.52%
  Ann. Volatility:      13.63%
  Max Drawdown:        -28.23%
  Sharpe Ratio:        0.5288
────────────────────────────────────────────────────────────
  Runtime Total:        38.10s
  Data Fetch:           11.14s
  Data Prep:             0.25s
  Calculation:           2.03s
  Reporting:            24.66s
============================================================