New: backtest inside ChatGPT. Get the ChatGPT plugin

Learn

A Recorded SPY Moving Average Backtest: Code, Trades and Results

A strategy can make money in a backtest and still trail buying and holding. This recorded Premiss test returned 6.13%, against 43.24% for its matched SPY baseline. Here are the rule, assumptions and complete files behind that comparison.

The exact rule and test period

The test uses daily SPY ETF bars, quoted in US dollars, from January 1, 2022 through December 31, 2025. Starting simulated capital is $10,000. It targets a fully invested long position when the mean of the last 20 completed closes exceeds the mean of the last 50, and cash otherwise. It does not short or borrow.

This is a target-state rule: the first eligible investment does not require a fresh crossover. Decisions use completed bars, with execution at the next eligible bar open. Inspect the saved Python to see the exact window and history checks rather than assuming every strategy called a moving average crossover behaves alike.

The simulation was completed on November 8, 2026. The export preserves the tested revision and strategy and baseline run identifiers. This article describes that existing record; it does not represent a newly rerun or live strategy.

The result beside the same-period baseline

The rule ended at $10,613.21, a 6.13% return. Its maximum drawdown was 28.63%. Buying and holding under the matched simulation settings ended at $14,323.87, a 43.24% return, with a 25.30% maximum drawdown. Under these assumptions, the moving average rule earned less and suffered a larger drawdown.

The record contains 1,078 equity observations for each curve and 21 strategy fills. A fill is one buy or sell execution, so this is not a claim of 21 completed round trips. The headline returns and drawdowns can be recalculated from the exported equity observations.

One selected 20/50 specification was used for this published case study. These results do not establish that another window, another market or a future period will behave similarly.

Walk through an actual losing trade

The first recorded buy is January 3, 2022: 20.97843416967358 units at $476.68, for $10,000 of notional. The next recorded fill sells the same quantity on January 24 at $439.80. Sale proceeds are $9,226.31534782244 and the recorded realized loss is $773.6846521775602 before rounding.

Those executions illustrate why a positive return at the end of a multi-year test does not describe the path along the way. Check the remaining fills and the intervening equity observations before deciding what you learned from the final percentage.

Costs and data limitations

This specific run selected zero basis points for fees and slippage, with $0 recorded fees. Spreads, market impact and taxes are outside its assumptions. Zero cost is a disclosed setting for inspecting this record, not a realistic default for every trading strategy. Test plausible costs separately before interpreting an idea for another purpose.

Prices are raw and unadjusted, with no dividend reinvestment. Premiss daily UTC buckets can include extended-session data and need not match an adjusted regular-session chart. The baseline is this run's matched price-only buy-and-hold simulation, not a published SPY total-return index.

Historical simulations are hypothetical. This example documents a research workflow and an underperforming rule; it is not a recommendation to trade SPY or a forecast of returns.

Inspect the files or specify a comparable experiment

Start with the settings report, then match the Python, fills and equity files. The report includes a SHA-256 hash of the tested Python so a downloaded code file can be checked against the recorded version. Keep all four files together.

To specify a comparable experiment in Premiss or the ChatGPT plugin, use this brief: ‘First confirm SPY daily data coverage and the history needed for warm-up. Test January 1, 2022 through December 31, 2025 with $10,000. Target 100% long when the 20-bar mean of completed closes is above the 50-bar mean, otherwise cash. No shorts or leverage. Execute after the decision at the next eligible bar open. For comparison with the published example, use zero fees and slippage and identify the raw-price and session conventions. Show the Python, every fill, equity and a matched buy-and-hold baseline.’

That brief is a reproduction aid, not a claim that a newly generated strategy has already matched the saved run. Verify the generated code and data assumptions, compare individual fills, and retain any differences as a separate experiment. After reproducing the baseline, change one assumption at a time and include realistic costs.