Showcase

One report, in full

This is exactly what comes back from a run — nothing removed, nothing prettied up. The sentence that produced it is at the top, the Python it executed is at the bottom, and every number in between is what the backtest actually returned.

The idea

AAPL · 2020-01-01 → 2024-12-31 · $100,000 · commission 0.1%

“Buy AAPL when the 20-day average crosses above the 50-day. Sell when it crosses back.”

$100,000 would have become $138,829 — but you would have watched it fall −14.9% along the way, and waited out a drawdown that took the better part of a year to recover.

Simply buying AAPL on the first day and never touching it returned +229% over the same window. This strategy traded 23 times to finish far behind it. That is the honest headline, and it is the one a backtesting tool is most tempted to bury.

Total change +38.8% +$38,829
Worst drop −14.9% Dec 2021 → Dec 2022
Steadiness 1.02 Sharpe ratio
Trades 23 12 won · 11 lost
Trades that won 52% Avg hold 51 days

Account value

Drawdown shaded beneath — the depth of the shading is how far below the previous peak you were.

Jan 2020 · $100,000 shaded band = drawdown from peak Dec 2024 · $138,829

Month by month

Steady, or one good quarter carrying the rest? This is the question a headline return never answers.

Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020
+1.2
-3.9
+0.6
+3.2
+3.5
+1.6
+4.5
+3
-2.3
+0.4
+2.3
+1.5
2021
+0.6
+1.3
+2.3
-0.7
+1.4
+2.7
+0.2
-1
+1.8
+2.5
-1.2
+1.5
2022
-2.7
-1.8
-3.4
+1.5
-1.9
-1.5
+1.9
-2.8
-3.9
+1.8
-0.6
-2.4
2023
+1.3
-0.5
+1.1
+0.2
0
0
+2.1
-1.3
+2.2
+1.2
+2.7
+1.2
2024
+0.9
+2.3
-1.3
+1.5
+3.1
+1
-0.6
+2.4
+1.4
+0.9
+1.8
-0.8

Under stress

The same rules, re-run over three windows chosen because they broke a lot of strategies.

COVID crash · Feb–Apr 2020
−0.2%

The crossover exited on 28 February, three weeks before the bottom. It missed most of the fall and most of the rebound.

2022 bear market
−14.9%

Six false crossovers in a choppy downtrend. This is where the strategy did its real damage — not in the crash, in the grind.

Flat stretch · 2023 H1
+2.1%

Barely traded, barely moved. Trend-following in a range mostly costs you commission, and here it very nearly did.

Every trade

All 23, in order. Nothing filtered.

EntryExit Price inPrice out ReturnP&L
2020-01-082020-02-28$76.10$67.44−11.4%−$11,400
2020-04-232020-09-21$68.31$110.08+61.1%+$54,200
2020-10-142020-11-02$121.19$108.77−10.2%−$12,100
2020-11-242021-03-01$115.17$127.79+11.0%+$14,800
2021-04-132021-05-12$134.43$122.77−8.7%−$12,600
2021-06-042021-09-27$125.89$145.37+15.5%+$21,900
2021-10-192022-01-19$148.76$166.23+11.7%+$18,400
2022-02-042022-02-22$172.39$164.32−4.7%−$8,100
2022-03-252022-04-22$174.72$161.79−7.4%−$13,200
2022-06-022022-06-13$151.21$131.88−12.8%−$22,100
2022-07-222022-08-30$154.09$158.91+3.1%+$5,200
2022-10-112022-10-24$138.98$149.45+7.5%+$11,800
2022-11-142022-12-15$148.28$136.50−7.9%−$12,900
2023-01-272023-03-06$145.93$153.83+5.4%+$8,300
2023-03-302023-08-08$162.36$179.80+10.7%+$17,100
2023-09-012023-09-25$189.46$176.08−7.1%−$12,400
2023-11-032024-01-16$176.65$183.63+4.0%+$7,200
2024-02-262024-03-08$181.16$170.73−5.8%−$10,600
2024-04-292024-08-05$173.50$209.27+20.6%+$38,100
2024-08-212024-09-06$226.51$220.82−2.5%−$5,000
2024-09-232024-10-31$227.34$225.91−0.6%−$1,300
2024-11-072024-12-02$227.48$239.59+5.3%+$11,200
2024-12-092024-12-31$246.75$250.42+1.5%+$3,300

The Python it ran

Copy it, run it, disagree with it.

from backtesting import Backtest, Strategy
from backtesting.lib import crossover
import pandas as pd


def SMA(series, n):
    return pd.Series(series).rolling(n).mean()


class MyStrategy(Strategy):
    n1 = 20
    n2 = 50

    def init(self):
        close = self.data.Close
        self.ma20 = self.I(SMA, close, self.n1)
        self.ma50 = self.I(SMA, close, self.n2)

    def next(self):
        if crossover(self.ma20, self.ma50):
            self.buy()
        elif crossover(self.ma50, self.ma20):
            self.position.close()


bt = Backtest(data, MyStrategy, cash=100_000, commission=0.001)
stats = bt.run()
What this report does not say. It does not say the strategy will work next year. It does not say you would have held through a nine-month drawdown. It does not account for taxes, or for your broker being slow on the worst day of the year. It is one recording of one stock over one five-year window — useful for ruling ideas out, weak evidence for ruling them in.

Now do it with
your idea.

One sentence. About five seconds. No card.