QuantJourney Backtester

QuantJourney Backtester

Share product feedback

✓

Thank you.

Your note is now in the QuantJourney inbox.

W09 · example_weights_09_intraday_1h_sma_trend.py

W09 Intraday SMA Trend1h

On hourly bars, hold each name only while its SMA(10) is above its SMA(30), equal weight across active names. A slower intraday-to-swing trend template.

What this example shows

This example shows how to build a 1h-bar moving-average trend weight-mode example with intraday signal generation, execution timing, cost assumptions and reporting at non-daily granularity.

The goal is educational: to demonstrate the full workflow for universe definition, signal generation, weight construction, risk overlays, execution assumptions, diagnostics and reproducible reporting.

Short-window execution example. Short-window intraday execution example. The dashboard emphasizes raw total return and drawdown; annualized CAGR and Sharpe are intentionally omitted because this sample is too short for a credible annual comparison.

Run setup

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

UniverseSPY · QQQ · IWM
Configured period2026-05-11 → 2026-07-11
BenchmarkSPY · SPDR S&P 500 ETF Trust
Initial capital$100,000
Data sourceyfinance
Engine / snapshot0.10.0 · 5387e17299744403
Weight ModeMode
1hGranularity
3Instruments
21Published plots
passedRun status

Dashboard

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

-3.49% Max DD
1.50% Total return
$1,502 Net profit

Selected plot gallery

21 published PNG artifacts selected for raw short-window interpretation. Charts marked Pro are generated by the hosted platform report pack; the rest come from the open-source engine output.

W09 Intraday SMA Trend1h Cumulative Returns
Cumulative Returns PNG
W09 Intraday SMA Trend1h Portfolio Drawdown
Portfolio Drawdown PNG
W09 Intraday SMA Trend1h Nav Composition
Nav Composition Pro PNG
W09 Intraday SMA Trend1h Percentage Weights
Percentage Weights PNG
W09 Intraday SMA Trend1h Blotter Trade Pnl
Blotter Trade Pnl Pro PNG
W09 Intraday SMA Trend1h Blotter Cumulative Pnl
Blotter Cumulative Pnl Pro PNG
W09 Intraday SMA Trend1h Blotter Costs
Blotter Costs Pro PNG
W09 Intraday SMA Trend1h Blotter Frequency
Blotter Frequency Pro PNG
W09 Intraday SMA Trend1h Blotter Holding Periods
Blotter Holding Periods Pro PNG
W09 Intraday SMA Trend1h Blotter Instrument Pnl
Blotter Instrument Pnl Pro PNG

Execution

W09 Intraday SMA Trend1h Blotter Trade Size
Blotter Trade Size Pro PNG
W09 Intraday SMA Trend1h Blotter Trade Timeline
Blotter Trade Timeline Pro PNG

Portfolio accounting

W09 Intraday SMA Trend1h Composition
Composition PNG

Performance

W09 Intraday SMA Trend1h Cumulative Log Returns
Cumulative Log Returns PNG

Drawdown

W09 Intraday SMA Trend1h Drawdown Recovery
Drawdown Recovery PNG
W09 Intraday SMA Trend1h Time Underwater
Time Underwater PNG

Distribution and optimization

W09 Intraday SMA Trend1h Return Quantiles
Return Quantiles PNG
W09 Intraday SMA Trend1h Returns Distribution
Returns Distribution Pro PNG

Strategy traces

W09 Intraday SMA Trend1h Strategy Trace IWM
Strategy Trace IWM Pro PNG
W09 Intraday SMA Trend1h Strategy Trace QQQ
Strategy Trace QQQ Pro PNG
W09 Intraday SMA Trend1h Strategy Trace SPY
Strategy Trace SPY Pro PNG

Metrics

Raw short-window KPIs are shown above; annualized ratios are intentionally not promoted.

Short-window execution example. Short-window intraday execution example. The dashboard emphasizes raw total return and drawdown; annualized CAGR and Sharpe are intentionally omitted because this sample is too short for a credible annual comparison.

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_weights_09_intraday_1h_sma_trend
File: <QJ_BACKTESTER_REPO>/strategies/example_weights_09_intraday_1h_sma_trend.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:11:50] [ERROR] [backtester] Failed to compute r_squared: Benchmark overlap 0.00% is below required 95.00%
[2026-07-11 12:11:50] [ERROR] [backtester] Failed to compute alpha: Benchmark overlap 0.00% is below required 95.00%
[2026-07-11 12:11:50] [ERROR] [backtester] Failed to compute beta: Benchmark overlap 0.00% is below required 95.00%
[2026-07-11 12:11:50] [ERROR] [backtester] Failed to compute tracking_error: Benchmark overlap 0.00% is below required 95.00%
[2026-07-11 12:11:50] [ERROR] [backtester] Failed to compute up_capture: Benchmark overlap 0.00% is below required 95.00%
[2026-07-11 12:11:50] [ERROR] [backtester] Failed to compute down_capture: Benchmark overlap 0.00% is below required 95.00%
[2026-07-11 12:11:51] [ERROR] [backtester] Failed to generate cumulative_returns_with_regime plot: Insufficient data for regime cumulative returns.
[2026-07-11 12:11:51] [ERROR] [backtester] Failed to generate portfolio_drawdown_with_regime plot: Insufficient data for regime drawdown plot.
<QJ_BACKTESTER_REPO>/backtester/portfolio/portfolio_plots.py:203: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  regime = regime.reindex(target_index).ffill()
<QJ_BACKTESTER_REPO>/backtester/portfolio/portfolio_plots.py:203: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  regime = regime.reindex(target_index).ffill()
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate rolling_beta plot: No valid beta values calculated.
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate rolling_beta_with_regime plot: No valid beta values calculated.
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate rolling_alpha plot: index -1 is out of bounds for axis 0 with size 0
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate rolling_alpha_with_regime plot: index -1 is out of bounds for axis 0 with size 0
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate rolling_information_ratio plot: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate rolling_information_ratio_with_regime plot: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate relative_performance plot: Insufficient data for relative performance plot.
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate factor_exposure plot: Insufficient data for factor exposure proxy.
[2026-07-11 12:11:53] [ERROR] [backtester] Failed to generate benchmark_regime_analysis plot: Insufficient data for benchmark regime analysis.
<QJ_BACKTESTER_REPO>/backtester/portfolio/portfolio_plots.py:203: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  regime = regime.reindex(target_index).ffill()

============================================================
  Strategy: ExampleWeights09_IntradaySMATrend1h
  Backtester: v0.10.0
  Period:   2026-05-11 → 2026-07-10
  Assets:   SPY, QQQ, IWM
────────────────────────────────────────────────────────────
  Initial NAV:  $    100,000.00
  Final NAV:    $    101,501.67
  Total Return:          1.50%
  Ann. Volatility:       8.23%
  Max Drawdown:         -3.49%
  Sharpe Ratio:        0.8858
────────────────────────────────────────────────────────────
  Runtime Total:        15.61s
  Data Fetch:            1.23s
  Data Prep:             0.22s
  Calculation:           0.78s
  Reporting:            13.35s
────────────────────────────────────────────────────────────
  Rebalance Policy: RebalancePolicy(freq=None, signal_change)
  Rebalances:              67
  Avg Days Btw:          10.7
============================================================