Use case · Claude Code
Ask for a backtest. Get the code, the chart and the numbers.
The slow part of testing a trading idea isn't the idea, it's the data: finding clean daily prices, adjusting them for splits and dividends, and getting them into a form your code can read. With Kaairos added to Claude Code, that part is one tool call. Kaairos saves the price history from your own Alpaca account as a CSV in your project, and Claude Code writes the backtest, runs it, fixes what breaks and draws the result.

The session
This is a real Claude Code session from 20 November 2026, condensed. The request is the whole prompt; nothing else was set up beforehand except an empty folder with a Python environment that has pandas and matplotlib.
What it made
Three files in the project folder: market-data/SPY_1Day.csv (the prices Kaairos saved), backtest.py (about 60 lines of pandas) and backtest.png, the chart below, which is Claude Code's own and unedited.

| 50/200 crossover | Buy and hold | |
|---|---|---|
| Total return | 157.3% | 279.1% |
| Yearly (CAGR) | 9.9% | 14.3% |
| Worst drawdown | −33.8% | −33.8% |
| Trades | 9 (5 buys, 4 sells) | 1 |
We checked the result independently. A total return of 279% over these ten years is what SPY did with dividends reinvested, and the −33.8% worst drop is the February–March 2020 crash. The code acts on each signal the next day, so it can't see the future, and the 200-day average is warmed up on data from before the window, so the strategy is live from the first day.
Why the data part matters
Most backtests people ask Claude Code for stall on data, or quietly use the wrong data. Unadjusted prices make every dividend look like a small crash and every split like a huge one; free sources often lack the last few months or rate-limit you halfway through a download. Kaairos's kaairos_prices tool fetches from your own Alpaca connection, adjusts for splits and dividends, and writes a plain CSV (time, open, high, low, close, volume) that any script can read.
| What you get | |
|---|---|
| Bar sizes | 1, 5, 15 and 30 minutes, 1 hour, 1 day, 1 week, 1 month |
| History | Back to 2016 on Alpaca's free market data |
| Adjustment | Splits and dividends, for stocks and ETFs; none for crypto |
| Freshness | Full-market prices up to 15 minutes ago, then the IEX exchange |
| Size limit | 200,000 bars per request for intraday sizes; daily data is never near it |
| Where it goes | market-data/<SYMBOL>_<size>.csv in your project, or a path you name |
The session above asked for prices from November 2015, and Kaairos returned what exists, starting 4 January 2016, with the first and last dates in its reply, so the limit is visible rather than papered over. The ten months before the test window were enough to warm up the 200-day average.
Ideas to try
- “Test RSI(2) mean reversion on QQQ since 2016: buy under 10, sell above 70. Compare with buying and holding.”
- “Run the 50/200 crossover on SPY, QQQ, IWM and EFA and show which it helped and which it hurt.”
- “Get 5-minute bars for NVDA for the last month and measure the average move in the first 30 minutes after the open.”
- “Backtest a monthly rebalance of 60% VTI and 40% BND since 2016, then show the drawdowns.”
- “Take the strategy that did best and have Kaairos check its signal every weekday at the close.”
The last one is where the two meet: Claude Code finds the rule, and Kaairos runs it on a schedule after the terminal is closed. See turning an answer into a routine.
Set it up
- In Kaairos, connect Alpaca in Settings › Trading. A paper account is free and uses real market prices.
- In Settings › Claude Code, click Add Kaairos.
- Start a new Claude Code session in your project folder and ask in plain words. Type
/mcpif you want to see Kaairos listed first.
Claude Code needs Python with pandas and matplotlib in the project, or it will offer to set them up. Kaairos must be open; if it isn't, the first request opens it.
Kaairos and Claude Code report what the data shows. Neither gives investment advice, and a backtest describes the past, not the future. The paper account uses practice money.
Limits
- History starts in 2016 on Alpaca's free data. Longer tests need another source.
- A backtest ignores what it isn't told about: this one assumed no costs, no slippage, no taxes and no interest on cash, and said so.
- Kaairos supplies the data; the code is Claude Code's. Read it before trusting a number, as you would any code.
- Claude Code and Kaairos run on the same Mac.
Fair questions
Do I need an Alpaca account?
Yes, connected in Kaairos. A paper account is free, needs only an email, and uses the same market data.
Are the prices adjusted?
Yes, for splits and dividends, on stocks and ETFs. Crypto prices aren't adjusted.
How far back does the data go?
To 2016 on Alpaca's free market data.
Can it place the trades the backtest suggests?
Only if you ask, and only with your OK in the Kaairos window for each order. Backtests never trade.
Who pays for what?
Claude Code runs on your own Claude plan. Kaairos's data comes from your Alpaca account, free for paper.
Download and go
Your AI agent, already set up.
One button to set up. Its own private AI, free. Claude, ChatGPT or Gemini when you want more.
A Mac with Apple silicon (M1 or later), macOS 15 Sequoia or later. 14-day refund.