O19 · example_orders_19_fx_momentum_lots.py O19 FX Momentum Lots
Trade four USD-quoted spot-FX pairs in the direction of six-month momentum. Position size is an integer number of standard lots, constrained by ATR risk and a per-pair notional cap.
Review the source on GitHub or return to all strategies.
What this example shows
This example shows how to build a daily-bar momentum-rotation order-mode example with ranking, positive-momentum filtering, rebalance cadence, position caps and portfolio reporting.
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.
UniverseEURUSD=X · GBPUSD=X · AUDUSD=X · NZDUSD=X
Configured period2010-01-04 → 2026-01-01
BenchmarkDX-Y.NYB · US Dollar Index
Initial capital$1,000,000
Data sourceyfinance
Engine / snapshot0.10.0 · 6013c278789d5d42
Order ModeMode
1dGranularity
4Instruments
42Published plots
passedRun status
Dashboard
Compact evidence view built from the same run packet: metrics, plots and run metadata.
-0.95% CAGR
-0.71 Sharpe
-15.25% Max DD
-14.20% Total return
4.07% Volatility
Metrics
Parsed from performance_report.txt.
Executive Summary
| Metric | Value | What it tells you |
| CAGR | -0.95% | Annualized compound growth rate across the full backtest period. |
| Net Profit | -$141,979 | Dollar profit generated above the initial capital after the simulated run. |
| Sharpe Ratio | -0.71 | Excess return per unit of volatility using the configured risk-free rate. |
| Max Drawdown | -15.25% | Largest peak-to-trough portfolio decline in percentage terms. |
Performance Breakdown
| Metric | Value | What it tells you |
| MTD | 0.20% | Month-to-date return at the report date. |
| QTD | -0.67% | Quarter-to-date return at the report date. |
| YTD | -2.57% | Year-to-date return at the report date. |
| 1Y | -2.69% | Trailing one-year return. |
| 3Y (ann.) | -2.21% | Annualized return over the trailing three-year window. |
| 5Y (ann.) | -1.10% | Annualized return over the trailing five-year window. |
| ITD | -14.20% | Inception-to-date total return. |
| Cumulative Return | -14.20% | Total compounded return over the full backtest period. |
| ATH Value | 1.0042 | Highest portfolio value reached when normalized to the initial portfolio base. |
| Drawdown from ATH | -14.56% | Current distance below the all-time high at the report date. |
Risk-Adjusted Metrics
| Metric | Value | What it tells you |
| Sharpe Ratio | -0.71 | Excess return divided by total volatility. |
| Smart Sharpe Ratio | -0.71 | Sharpe variant adjusted for serial correlation effects. |
| Sortino Ratio | -0.97 | Excess return divided by downside volatility only. |
| Smart Sortino Ratio | -0.97 | Sortino variant adjusted for serial correlation effects. |
| Calmar Ratio | -0.06 | Annualized return divided by absolute max drawdown. |
| Omega Ratio | 0.96 | Ratio of gains above a threshold to losses below it. |
| Information Ratio | -0.37 | Active return divided by tracking error versus the benchmark. |
Benchmark Comparison
| Metric | Value | What it tells you |
| Benchmark Name | US Dollar Ind… | Benchmark used for comparison, beta, active return and information ratio. |
| Benchmark MTD | -1.19% | Benchmark month-to-date return. |
| Benchmark QTD | 1.17% | Benchmark quarter-to-date return. |
| Benchmark YTD | -5.34% | Benchmark year-to-date return. |
| Benchmark 1Y | -3.37% | Benchmark trailing one-year return. |
| Benchmark 3Y (ann.) | -2.63% | Benchmark annualized trailing three-year return. |
| Benchmark 5Y (ann.) | -0.72% | Benchmark annualized trailing five-year return. |
| Benchmark ITD | 18.48% | Benchmark inception-to-date total return over the strategy sample. |
| Excess Return YTD | 1.73% | Strategy return minus benchmark return for the year-to-date window. |
| Active Return YTD (ann.) | 1.95% | Annualized active return for the year-to-date window. |
| Excess Return Full Period | -38.29% | Arithmetic difference of cumulative returns in percentage points — strategy minus benchmark over the whole sample. |
| Active Return Full Period (ann.) | -2.77% | Annualized active return across the full sample. |
Risk Metrics
| Metric | Value | What it tells you |
| Vol (Recent Window) | 1.29% | Annualized volatility over the most recent rolling window. |
| Vol (Rolling Window) | 4.07% | 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%) | 5.86% | High-end volatility estimate from the rolling distribution. |
| VaR (95%) CF Normal | 0.40% | One-period 95% Value-at-Risk under a normal approximation. |
| VaR (95%) Stress Vol | 0.63% | Stress-calibrated 95% Value-at-Risk estimate. |
| Expected Shortfall | 0.84% | Average loss conditional on being beyond the VaR threshold. |
| Stress Tail Obs | 827 | |
| Max Drawdown | -15.25% | Worst percentage peak-to-trough decline. |
| Max Drawdown ($) | -$153,126 | Worst peak-to-trough decline translated into dollars for the configured capital. |
| Distribution Skewness | -0.0595 | Asymmetry of the return distribution. |
| Distribution Kurtosis | 3.9989 | Tail heaviness relative to a normal distribution. |
| Tail Risk Ratio | 1.0536 | Upside tail magnitude divided by downside tail magnitude. |
| Worst Loss Magnitude | 1.55% | Worst single-period loss in the report frequency. |
| 5 Worst Days Avg Loss | 1.35% | Average return across the five worst days. |
Market Dynamics
| Metric | Value | What it tells you |
| Correlation | 0.04 | Linear co-movement between strategy and benchmark returns. |
Strat Characteristics
| Metric | Value | What it tells you |
| Inception Date | 2010-01-04 | First date included in the performance track record. |
| Current Date | 2025-12-31 | Final report date for the sample. |
| Track Record | 15Y 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.30% | Current or average long exposure depending on report configuration. |
| Short Exposure | 29.20% | |
| Gross Exposure | 58.50% | Total absolute exposure across long and short positions. |
| Position Count | 4 | Number of instruments in the active universe or current holdings. |
| Concentration | 8.60% | Largest or representative concentration measure in the portfolio. |
| Raw Concentration | 25.12% | Concentration before final clipping, accounting or reporting adjustments. |
| Effective Positions | 4 | Diversification estimate based on concentration rather than simple instrument count. |
Exposure Path Checks
| Metric | Value | What it tells you |
| Max Gross Exposure | 73.63% | Highest gross exposure reached during the run. |
| Avg Gross Exposure | 56.78% | Average absolute exposure across the backtest. |
| Max Long Exposure | 65.81% | Highest long-side exposure reached during the run. |
| Max Short Exposure | 70.97% | |
| Min Cash Sleeve | 34.19% | Lowest cash percentage observed in the simulated portfolio. |
| Max Cash Sleeve | 170.97% | 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 (Day) | 48.14% | Percentage of daily observations with positive return. |
| Win Rate (Month) | 43.75% | Percentage of positive months. |
| Recovery Factor | -0.06 | Net profit divided by maximum drawdown. |
| Expectancy | -$2.56 | Average expected profit per trade. |
| Largest Loss | -$3.72 | Largest single losing trade. |
| Average Loss | -$2.56 | Mean loss across losing trades. |
| Max Consecutive Win Days | 11 | Longest streak of positive daily returns. |
| Max Consecutive Loss Days | 10 | Longest streak of negative daily returns. |
| Total Trades | 735 | Total buy and sell trade events. |
| Buy Trades | 366 | Number of buy-side trade events. |
| Sell Trades | 369 | Number of sell-side trade events. |
| Total FIFO Lot RTs | 700 | Matched entry-exit trade cycles. |
| Long FIFO Lot RTs | 326 | Round trips for long positions. |
| Short FIFO Lot RTs | 374 | |
| Avg Lot Holding Period | 36 days | Average time a matched position remains open. |
| Median Lot Holding Period | 6 days | Median matched holding period. |
| Turnover (ann.) | 613.88% | Annualized trading activity relative to portfolio value. |
| Avg Trade Size | $244,074 | Average notional size of trade events. |
Advanced Risk
| Metric | Value | What it tells you |
| CVaR / Expected Shortfall (95%) | 0.84% | Average loss conditional on being beyond the VaR threshold. |
| Serenity Index | -0.09 | Return quality measure that penalizes drawdown severity and persistence. |
Advanced Trading
| Metric | Value | What it tells you |
| Gain-to-Pain Ratio | 0.96 | Total gains divided by total losses over the period. |
| Drawdown-Vol Adj. Return | -0.01 | 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) | -5.00% | Theoretical capital fraction implied by win/loss profile. |
| Tail Ratio | 1.05 | Upper-tail return magnitude divided by lower-tail magnitude. |
Operational Metrics
| Metric | Value | What it tells you |
| Total Commission | $1,793.94 | Total simulated commission paid across all trade events. |
| Commission (% Vol) | 0.00% | Commission as a percentage of traded volume. |
| Total Volume | $179,394,054 | Total simulated notional traded. |
| Instruments | 4 | Number of instruments traded or evaluated. |
Consistency Checks
| Metric | Value | What it tells you |
| Trade/2x FIFO Lot RT | 0.53 | Compares trade count to twice the FIFO lot round-trip count. |
| Avg Trades / FIFO Lot RT | 1.05 | Average number of trade events per FIFO lot round trip. |
| Strict Lot-Match Check | ✗ | Boolean check that FIFO lot matching completed cleanly. |
| Volume Consistent | ✗ | Boolean sanity check for volume accounting. |
| RT Position-Day Load | 6.07 | 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 | 2010-01-04 | First date available in the input data. |
| Data End | 2026-01-01 | Final date available in the input data. |
| Trading Days | 4165 | Number of trading-day observations in the dataset. |
| Reporting Frequency | daily | Frequency used for returns and report metrics. |
| Reporting Observations | 4165 | Number of observations used in the report calculations. |
| Reporting Periods/Year | 252 | Annualization factor used for daily metrics. |
| Initial Capital | $1,000,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 | d49e09511fc30… | Run fingerprint tying configuration and data context to this output. |
| Config Hash | 3508ec4abe2e0… | Hash of configuration choices used by the run. |
| Data Hash | 6a2149e1393ad… | 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 | 16 | 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 | 0.01% | Average strategy return across evaluated crisis windows. |
| Worst Crisis | EU Debt Crisis | Crisis window with the worst strategy result. |
| Best Crisis | 2022 Rate Sho… | Crisis or recovery window with the best strategy result. |
| Crisis Hit Rate | 50.00% | 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_19_fx_momentum_lots
File: <QJ_BACKTESTER_REPO>/strategies/example_orders_19_fx_momentum_lots.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
[2026-07-11 12:04:58] [ERROR] [backtester] Failed to compute r_squared: Benchmark overlap 85.16% is below required 95.00%
[2026-07-11 12:04:58] [ERROR] [backtester] Failed to compute alpha: Benchmark overlap 85.16% is below required 95.00%
[2026-07-11 12:04:58] [ERROR] [backtester] Failed to compute up_capture: Benchmark overlap 85.16% is below required 95.00%
[2026-07-11 12:04:58] [ERROR] [backtester] Failed to compute tracking_error: Benchmark overlap 85.16% is below required 95.00%
[2026-07-11 12:04:58] [ERROR] [backtester] Failed to compute beta: Benchmark overlap 85.16% is below required 95.00%
[2026-07-11 12:04:58] [ERROR] [backtester] Failed to compute down_capture: Benchmark overlap 85.16% is below required 95.00%
============================================================
Strategy: ExampleOrders19_FXMomentumLots
Backtester: v0.10.0
Period: 2010-01-04 → 2025-12-31
Assets: EURUSD=X, GBPUSD=X, AUDUSD=X, NZDUSD=X
────────────────────────────────────────────────────────────
Initial NAV: $ 1,000,000.00
Final NAV: $ 858,021.20
Total Return: -14.20%
Ann. Volatility: 4.81%
Max Drawdown: -15.25%
Sharpe Ratio: -0.6713
────────────────────────────────────────────────────────────
Runtime Total: 31.10s
Data Fetch: 5.05s
Data Prep: 0.17s
Calculation: 3.38s
Reporting: 22.48s
============================================================