shadowfolio

Guides

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

  1. 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.
  2. Answer the open questions. If you leave something out, Shadowfolio asks, and shows the default it would use. Say "use the defaults" to skip.
  3. 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.
  4. Change a rule. Edit any rule in the card or tell ChatGPT what to change, and run it again.
  5. 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 ChatGPTSpreadsheetCode (Python and a data library)Asking ChatGPT alone
You describe the rulesIn plain English; it asks for anything you left openAs formulas, one column per ruleAs a programIn plain English
PricesEnd-of-day prices for US stocks and ETFs, refreshed dailyYou download and paste themYou fetch themNone: it can't run your rules on real prices without a tool
ResultsReturn, max drawdown, Sharpe, win rate, trades, curve against a benchmarkWhatever you buildWhatever you buildEstimates from memory, which can be wrong
Forward trackingYes: updated after every US close from the day you saveOnly if you update it by handOnly if you schedule itNo
LimitsDaily closes only; US stocks and ETFs; last 12 monthsSlow for many tickersTakes time to write and checkNo 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.

More guides