How to backtest a stock trading strategy in ChatGPT
ChatGPT on its own can describe a strategy but can't run it on real prices, so its numbers are guesses. With the Shadowfolio plugin you describe the strategy in plain English, it becomes explicit rules, and Shadowfolio runs them on the last 12 months of end-of-day prices for US stocks and ETFs, reporting return, max drawdown, Sharpe ratio, win rate and trades next to a benchmark.
Updated · The Open Apps, Inc.
Step by step
- Describe the idea. Say what to trade (your tickers, the S&P 500, a sector, or popular ETFs), when to buy, when to sell, how often to rebalance and how to size positions.
- Answer the open questions. If you leave something out, Shadowfolio asks, and shows the default it would use. Say "use the defaults" to skip.
- Read the result. The card shows the equity curve against the benchmark (SPY unless you name another), total return, max drawdown, Sharpe ratio, win rate and the number of trades.
- Change a rule. Edit any rule in the card or tell ChatGPT what to change, and run it again.
- Track it forward. Say "save it": Shadowfolio starts a hypothetical 10,000 portfolio from the latest close and updates it every trading day.
What counts as a rule
Buy and sell rules can use the price against a moving average (up to 252 days), a fast and a slow average, RSI, the return over a period, or the distance from a recent high. Any rule can look at another ticker, such as "only while SPY is above its 200-day average". Sells can also be a stop loss, a take-profit or a holding period.
Trades fill at each day's close with a cost of 0.05% per buy or sell unless you set another. Money not invested sits in cash at 0%, or in a fund you name.
Ways to do it
| Shadowfolio in ChatGPT | Spreadsheet | Code (Python and a data library) | Asking ChatGPT alone | |
|---|---|---|---|---|
| You describe the rules | In plain English; it asks for anything you left open | As formulas, one column per rule | As a program | In plain English |
| Prices | End-of-day prices for US stocks and ETFs, refreshed daily | You download and paste them | You fetch them | None: it can't run your rules on real prices without a tool |
| Results | Return, max drawdown, Sharpe, win rate, trades, curve against a benchmark | Whatever you build | Whatever you build | Estimates from memory, which can be wrong |
| Forward tracking | Yes: updated after every US close from the day you save | Only if you update it by hand | Only if you schedule it | No |
| Limits | Daily closes only; US stocks and ETFs; last 12 months | Slow for many tickers | Takes time to write and check | No real data |
Each way has its place: a spreadsheet or code gives full control and any data you can get; Shadowfolio is for testing an idea in a few minutes without either.
Use it in ChatGPT
Add Shadowfolio in ChatGPT (coming soon to the plugin directory), then say:
- Backtest holding QQQ only while it's above its 100-day average, otherwise cash, checked weekly.
Shadowfolio runs only the rules you describe. It never suggests investments, never gives advice and never places trades.
Questions
- Can ChatGPT backtest a strategy by itself?
- Not on real prices. Without a tool it has no price data to run rules on, so any numbers it gives are estimates. A plugin like Shadowfolio runs the rules on actual end-of-day prices.
- How far back does it test?
- The last 12 months of trading days, ending at the latest US close.
- Does it include dividends?
- Yes. It uses adjusted closes, so dividends and splits are counted in the returns.
- Is a good backtest a reason to invest?
- No. A backtest shows what rules would have done on past prices; it says nothing reliable about the future, and Shadowfolio gives no investment advice.