QuantJourney Backtester

QuantJourney Backtester

Share product feedback

✓

Thank you.

Your note is now in the QuantJourney inbox.

O10 · example_orders_10_trailing_stop_rsi.py

O10 Trailing Stop RSI

Buy oversold RSI readings, then let a 5% trailing stop handle risk.

What this example shows

This example shows how to build a daily-bar RSI mean-reversion order-mode example with entry rules, trailing risk management, fill simulation and order-state tracking.

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 · QQQ · IWM
Configured period2001-01-03 → 2026-01-01
BenchmarkSPY · SPDR S&P 500 ETF Trust
Initial capital$100,000
Data sourceyfinance
Engine / snapshot0.10.0 · 7680b7af40fb3a59
Order ModeMode
1dGranularity
3Instruments
42Published plots
passedRun status

Dashboard

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

-0.52% CAGR
-0.41 Sharpe
-38.99% Max DD
-12.16% Total return
5.20% 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.

O10 Trailing Stop RSI Cumulative Returns
Cumulative Returns PNG
O10 Trailing Stop RSI Portfolio Drawdown
Portfolio Drawdown PNG
O10 Trailing Stop RSI Monthly Returns Heatmap
Monthly Returns Heatmap PNG
O10 Trailing Stop RSI Annual Returns
Annual Returns PNG
O10 Trailing Stop RSI Nav Composition
Nav Composition Pro PNG
O10 Trailing Stop RSI Percentage Weights
Percentage Weights PNG
O10 Trailing Stop RSI Crisis Summary
Crisis Summary Pro PNG
O10 Trailing Stop RSI Correlation Heatmap
Correlation Heatmap PNG
O10 Trailing Stop RSI Blotter Trade Pnl
Blotter Trade Pnl Pro PNG
O10 Trailing Stop RSI Blotter Cumulative Pnl
Blotter Cumulative Pnl Pro PNG

Performance

O10 Trailing Stop RSI Cumulative Log Returns
Cumulative Log Returns PNG
O10 Trailing Stop RSI Relative Performance
Relative Performance Pro PNG

Risk and exposure

O10 Trailing Stop RSI Asset Risk Contribution
Asset Risk Contribution Pro PNG

Crisis and regimes

O10 Trailing Stop RSI Benchmark Regime Analysis
Benchmark Regime Analysis Pro PNG
O10 Trailing Stop RSI Crisis Periods
Crisis Periods Pro PNG
O10 Trailing Stop RSI Cumulative Returns With Regime
Cumulative Returns With Regime Pro PNG

Execution

O10 Trailing Stop RSI Blotter Costs
Blotter Costs Pro PNG
O10 Trailing Stop RSI Blotter Frequency
Blotter Frequency Pro PNG
O10 Trailing Stop RSI Blotter Holding Periods
Blotter Holding Periods Pro PNG
O10 Trailing Stop RSI Blotter Instrument Pnl
Blotter Instrument Pnl Pro PNG
O10 Trailing Stop RSI Blotter Trade Size
Blotter Trade Size Pro PNG
O10 Trailing Stop RSI Blotter Trade Timeline
Blotter Trade Timeline Pro PNG
O10 Trailing Stop RSI Turnover Vs Performance
Turnover Vs Performance Pro PNG

Portfolio accounting

O10 Trailing Stop RSI Composition
Composition PNG

Drawdown

O10 Trailing Stop RSI Drawdown Recovery
Drawdown Recovery PNG
O10 Trailing Stop RSI Portfolio Drawdown With Regime
Portfolio Drawdown With Regime Pro PNG
O10 Trailing Stop RSI Time Underwater
Time Underwater PNG

Distribution and optimization

O10 Trailing Stop RSI Efficient Frontier
Efficient Frontier Pro PNG
O10 Trailing Stop RSI Expected Return Profile
Expected Return Profile Pro PNG
O10 Trailing Stop RSI Omega Curve
Omega Curve Pro PNG
O10 Trailing Stop RSI Return Quantiles
Return Quantiles PNG
O10 Trailing Stop RSI Returns Distribution
Returns Distribution Pro PNG

Rolling diagnostics

O10 Trailing Stop RSI Rolling Max Dd
Rolling Max Dd Pro PNG
O10 Trailing Stop RSI Rolling Sharpe
Rolling Sharpe Pro PNG
O10 Trailing Stop RSI Rolling Volatility
Rolling Volatility Pro PNG
O10 Trailing Stop RSI Rolling Alpha
Rolling Alpha Pro PNG
O10 Trailing Stop RSI Rolling Asset Correlations
Rolling Asset Correlations PNG
O10 Trailing Stop RSI Rolling Beta
Rolling Beta Pro PNG
O10 Trailing Stop RSI Rolling Sortino Ratio
Rolling Sortino Ratio PNG
O10 Trailing Stop RSI Rolling Tail Risk
Rolling Tail Risk Pro PNG
O10 Trailing Stop RSI Rolling Var Cvar
Rolling Var Cvar PNG

Simulation

O10 Trailing Stop RSI Monte Carlo Simulation
Monte Carlo Simulation Pro PNG

Metrics

Parsed from performance_report.txt.

Executive Summary

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

Performance Breakdown

Metric Value What it tells you
MTD 0.27% Month-to-date return at the report date.
QTD 2.77% Quarter-to-date return at the report date.
YTD -4.60% Year-to-date return at the report date.
1Y -4.91% Trailing one-year return.
3Y (ann.) 2.10% Annualized return over the trailing three-year window.
5Y (ann.) 0.03% Annualized return over the trailing five-year window.
ITD -12.16% Inception-to-date total return.
Cumulative Return -12.16% Total compounded return over the full backtest period.
ATH Value 1.0078 Highest portfolio value reached when normalized to the initial portfolio base.
Drawdown from ATH -12.84% Current distance below the all-time high at the report date.

Risk-Adjusted Metrics

Metric Value What it tells you
Sharpe Ratio -0.41 Excess return divided by total volatility.
Smart Sharpe Ratio -0.42 Sharpe variant adjusted for serial correlation effects.
Sortino Ratio -0.55 Excess return divided by downside volatility only.
Smart Sortino Ratio -0.55 Sortino variant adjusted for serial correlation effects.
Calmar Ratio -0.01 Annualized return divided by absolute max drawdown.
Omega Ratio 0.98 Ratio of gains above a threshold to losses below it.
Information Ratio -0.67 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 693.52% Benchmark inception-to-date total return over the strategy sample.
Excess Return YTD -22.32% Strategy return minus benchmark return for the year-to-date window.
Active Return YTD (ann.) -22.51% Annualized active return for the year-to-date window.
Excess Return Full Period -705.68% Arithmetic difference of cumulative returns in percentage points — strategy minus benchmark over the whole sample.
Active Return Full Period (ann.) -9.18% Annualized active return across the full sample.

Risk Metrics

Metric Value What it tells you
Vol (Recent Window) 4.69% Annualized volatility over the most recent rolling window.
Vol (Rolling Window) 5.20% 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%) 9.57% High-end volatility estimate from the rolling distribution.
VaR (95%) CF Normal 0.55% One-period 95% Value-at-Risk under a normal approximation.
VaR (95%) Stress Vol 0.97% Stress-calibrated 95% Value-at-Risk estimate.
Expected Shortfall 1.50% Average loss conditional on being beyond the VaR threshold.
Stress Tail Obs 1251
Tracking Error 15.65% Annualized volatility of active return versus the benchmark.
Max Drawdown -38.99% Worst percentage peak-to-trough decline.
Max Drawdown ($) -$39,292 Worst peak-to-trough decline translated into dollars for the configured capital.
Distribution Skewness -1.0369 Asymmetry of the return distribution.
Distribution Kurtosis 20.4467 Tail heaviness relative to a normal distribution.
Tail Risk Ratio 1.1781 Upside tail magnitude divided by downside tail magnitude.
Worst Loss Magnitude 5.03% Worst single-period loss in the report frequency.
5 Worst Days Avg Loss 3.56% Average return across the five worst days.

Market Dynamics

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

Strat Characteristics

Metric Value What it tells you
Inception Date 2001-01-03 First date included in the performance track record.
Current Date 2025-12-31 Final report date for the sample.
Track Record 24Y 11M Length of the tested track record.
Strategy Type Long-Short 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 29.32% Current or average long exposure depending on report configuration.
Gross Exposure 29.32% Total absolute exposure across long and short positions.
Position Count 2 Number of instruments in the active universe or current holdings.
Concentration 4.30% Largest or representative concentration measure in the portfolio.
Raw Concentration 50.00% Concentration before final clipping, accounting or reporting adjustments.
Effective Positions 3 Diversification estimate based on concentration rather than simple instrument count.

Exposure Path Checks

Metric Value What it tells you
Max Gross Exposure 47.90% Highest gross exposure reached during the run.
Avg Gross Exposure 14.30% Average absolute exposure across the backtest.
Max Long Exposure 47.90% Highest long-side exposure reached during the run.
Min Cash Sleeve 52.10% 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) 39.75% Percentage of trades that were profitable.
Win Rate (Day) 26.92% Percentage of daily observations with positive return.
Win Rate (Month) 42.67% Percentage of positive months.
Profit Factor (Trade) 0.91 Gross winning trade PnL divided by gross losing trade PnL.
Recovery Factor -0.01 Net profit divided by maximum drawdown.
Expectancy -$24.08 Average expected profit per trade.
Avg Gain/Loss Ratio (Trade) 1.39 Average winning trade size divided by average losing trade size.
Largest Win $2,205.09 Largest single winning trade.
Largest Loss -$1,743.07 Largest single losing trade.
Average Win $651.92 Mean profit across winning trades.
Average Loss -$470.00 Mean loss across losing trades.
Max Consecutive Win Days 10 Longest streak of positive daily returns.
Max Consecutive Loss Days 9 Longest streak of negative daily returns.
Total Trades 1104 Total buy and sell trade events.
Buy Trades 553 Number of buy-side trade events.
Sell Trades 551 Number of sell-side trade events.
Total FIFO Lot RTs 551 Matched entry-exit trade cycles.
Long FIFO Lot RTs 551 Round trips for long positions.
Avg Lot Holding Period 15 days Average time a matched position remains open.
Median Lot Holding Period 9 days Median matched holding period.
Turnover (ann.) 326.71% Annualized trading activity relative to portfolio value.
Avg Trade Size $12,293 Average notional size of trade events.

Advanced Risk

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

Advanced Trading

Metric Value What it tells you
Gain-to-Pain Ratio 0.98 Total gains divided by total losses over the period.
Drawdown-Vol Adj. Return -0.00 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) -53.49% Theoretical capital fraction implied by win/loss profile.
Tail Ratio 1.18 Upper-tail return magnitude divided by lower-tail magnitude.

Operational Metrics

Metric Value What it tells you
Total Commission $1,357.19 Total simulated commission paid across all trade events.
Commission (% Vol) 0.01% Commission as a percentage of traded volume.
Total Volume $13,571,913 Total simulated notional traded.
Instruments 3 Number of instruments traded or evaluated.

Consistency Checks

Metric Value What it tells you
Trade/2x FIFO Lot RT 1.00 Compares trade count to twice the FIFO lot round-trip count.
Avg Trades / FIFO Lot RT 2.00 Average number of trade events per FIFO lot round trip.
Strict Lot-Match Check ✓ Boolean check that FIFO lot matching completed cleanly.
Volume Consistency 1.00 Internal consistency score for volume reconstruction.
Volume Consistent ✓ Boolean sanity check for volume accounting.
RT Position-Day Load 1.35 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 2001-01-03 First date available in the input data.
Data End 2026-01-01 Final date available in the input data.
Trading Days 6286 Number of trading-day observations in the dataset.
Reporting Frequency daily Frequency used for returns and report metrics.
Reporting Observations 6286 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 FixedBpsCommi… 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 819ee8288401c… Run fingerprint tying configuration and data context to this output.
Config Hash 16b969aa1f458… Hash of configuration choices used by the run.
Data Hash 45589f8c8991a… 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 19 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 -2.40% Average strategy return across evaluated crisis windows.
Worst Crisis GFC / Lehman Crisis window with the worst strategy result.
Best Crisis Brexit Crisis or recovery window with the best strategy result.
Crisis Hit Rate 52.63% 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_10_trailing_stop_rsi
File: <QJ_BACKTESTER_REPO>/strategies/example_orders_10_trailing_stop_rsi.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: ExampleOrders10_TrailingStopRSI
  Backtester: v0.10.0
  Period:   2001-01-03 → 2025-12-31
  Assets:   SPY, QQQ, IWM
────────────────────────────────────────────────────────────
  Initial NAV:  $    100,000.00
  Final NAV:    $     87,837.97
  Total Return:        -12.16%
  Ann. Volatility:       5.69%
  Max Drawdown:        -38.99%
  Sharpe Ratio:       -0.4142
────────────────────────────────────────────────────────────
  Runtime Total:        33.07s
  Data Fetch:            3.17s
  Data Prep:             0.31s
  Calculation:           2.83s
  Reporting:            26.73s
============================================================