I Built an INSANE AI Trading Bot with Fable 5.2 (Full Guide)
Set up the project in Claude Code, verify the data split and proof checks, compare strategies without look-ahead bias, and optionally move a selected strategy to TradingView and a cautious 1
AI Trading Bot Setup Guide
AI Trading Bot Setup Guide: Fable 5.2 vs Opus 5.5
From the Miles Deutscher Finance video where Claude Fable 5.2 and Claude Opus 5.5 each built 100 Bitcoin trading strategies, and all 200 were then tested on a year of data neither AI had ever seen.
This one file takes you from an empty folder to a strategy running on Bybit:
- Build a fair test, with a hidden year the AIs can't see
- Let two AIs build 100 strategies each
- Unlock the hidden year and mark the exam with 5 tests
- Turn a strategy into a TradingView Pine Script and backtest it on the chart
- Connect it to Bybit and forward test it slowly
Not financial advice. This is an educational experiment. Trading perpetual futures is risky, and the main lesson of the video is that most strategies that look great on paper don't hold up. Start on demo, or with money you can afford to lose.
How to use this file
Easiest way: drag this file into Claude (Claude Code works best, because it can run the code) and type:
Set this up with me, one step at a time.
Claude will ask you a few questions and walk you through every part.
Manual way: follow Parts 1 to 9 yourself. Copy each prompt exactly as written and only change text in [BRACKETS].
For Claude: how to run this guide
*Instructions for the AI. Skip this section if you're following along yourself.*
You are helping a member of the Miles Deutscher Finance community recreate the "Fable 5.2 vs Opus 5.5" AI trading test and, if they want, connect a strategy to Bybit. Run it like this:
- Before Part 1, ask these one at a time:
- Are you in Claude Code on your computer, or in a Claude chat? Parts 1 to 7 need Claude Code (or another coding agent that can run Python and read files). If they're in a chat, guide them and have them paste the prompts into Claude Code.
- Mac, Windows or Linux? Is Python 3 installed?
- The full head-to-head (Fable 5.2 vs Opus 5.5), or one model only?
- How far do you want to go: just the test, up to a TradingView backtest, or all the way to a Bybit bot?
- Go one Part at a time. Explain the Part in two or three plain sentences, give the exact steps, and wait for the person to say it's done before moving on.
- Give every prompt word for word. Fill in only the
[BRACKETS]and leave every other word, date and number as it is. The dates and proof-check numbers are what prove the person's setup matches the video. - If you are Claude Code running inside the person's project folder, you can act as the Setup session (Parts 2 and 4) yourself. Never write or test the 100 strategies in that session: Part 3 must run in fresh sessions opened inside
fable/andopus/, or the test isn't fair. - Never ask for, accept or repeat a password, API key, secret, seed phrase or Bybit webhook URL in chat. The webhook URL only goes from Bybit into TradingView.
- Check with the person before anything touches an exchange account. Default to the safest option in Part 8, Step 1 (paper on TradingView first, then Bybit Demo, then a small sub-account), always at 1x leverage, with a forward test before any real size. Before the bot goes live, make sure they've done Step 6's position match.
- Don't promise profits or call a strategy "proven". If they want to go live, take them through the five tests (Part 6) and the forward test (Part 9) first.
- Finish with a short summary: what's set up, which strategy they picked and why, and their next step.
What you need
| What | Why | Notes |
|---|---|---|
| A Claude plan that includes Claude Code | The AIs build and test the strategies | Miles used Fable 5.2 and Opus 5.5 for the build. Either one works for the Setup session |
| Python 3 | Runs the backtests | Claude installs pandas and numpy for you if they're missing |
| TradingView, paid plan | Backtest the strategy on a chart (Part 7) and send its signals to Bybit (Part 8) | Webhooks only work on paid plans (Essential or higher), with two-factor authentication turned on |
| Bybit account | Runs the bot (Part 8) | Unlock $30K+ in welcome rewards š https://partner.bybit.com/b/166453. Bybit isn't available in every country (the US, for example), so check first |
What happened in the video
Both AIs saw Bitcoin's 4-hour candles from April 2020 to October 2025. The year after that (1 Nov 2025 to 1 Nov 2026) was locked away. Then every strategy was scored on that hidden year, where Bitcoin fell 29.44%.
| Fable 5.2's pick (s100) | Opus 5.5's pick (s084) | |
|---|---|---|
| The idea | Breakouts, only when 2 of 3 slow trend signals agree | Breakouts in the direction of the 6-month trend |
| On paper (Apr 2020 to Oct 2025) | +791% ($10K to about $89K), max drawdown -49% | +331%, max drawdown -61% |
| Its own "biggest risk" | A sideways, whipsawing market | A sideways market |
| Test 1: hidden year | +5.8%: PASS | -8.7%: FAIL |
| Test 2: settings nudged 20% | 10 of 10 versions profitable: PASS | 2 of 6 profitable: FAIL |
| Test 3: double fees | +0.64%: PASS (just) | -13.5%: FAIL |
| Test 4: trades shuffled 1,000 times | Lost money in 44%: FAIL | Lost money in 61%: FAIL |
| Test 5: luck check | Beat 63% of random twins: FAIL | Beat 44%: FAIL |
| Score | 3 / 5 | 0 / 5 |
The parts worth remembering:
- Holding Bitcoin beat everything on paper. Buy and hold made +1,622% over the paper period (but sat 77% below its high at the worst point). Only 2 of Fable's strategies and none of Opus's beat it.
- The best backtest flopped. Fable's s014 had the best paper score of all 200 (Sharpe 1.44, $10K to about $181K). On the hidden year it made about 3% and came 140th out of 200.
- A big loser won the year. Opus's s010 lost 67% on paper (194th out of 200). On the hidden year it made +83%, the biggest return of all 200.
- Paper barely predicted reality. How well the paper ranking matched the hidden-year ranking, where 1 is perfect and 0 is no link: Fable 0.14, Opus 0.19.
- 195 of 200 beat holding Bitcoin in the hidden year and 148 made money. That's a low bar in a falling year: most did it by going short or sitting in cash.
- Only 7 of 200 passed the luck check, about what you'd expect from pure chance.
- Both AIs came to the same conclusion when shown their results: "pick a portfolio, not a champion" (Fable) and "bet on a basket, not one champion" (Opus).
Your run will be different. The AIs write new strategies every time, so your 200 won't match Miles's one for one. The proof checks in Parts 2 and 4 use fixed rules, though, so those numbers must match exactly.
Words used in this guide
| Word | Plain English |
|---|---|
| Backtest | Running a strategy on past prices to see what it would have made. A mock exam where you've already seen the answers |
| In-sample | The data the AI can see while it builds (Apr 2020 to Oct 2025) |
| Out-of-sample / hidden year | Data the AI never saw (Nov 2025 to Nov 2026). The real exam |
| Overfitting | Tuning a strategy so tightly to past data that it only works on that data |
| Look-ahead | A strategy accidentally using future prices. The backtester catches and rejects it |
| Breakout | Price pushing past its recent high or low |
| Slippage | The gap between the price you want and the price you actually get |
| Max drawdown | The worst fall from a high point to a low. How much pain you'd sit through |
| Sharpe ratio | Return compared with how bumpy the ride was, scaled to a year. Above 1 is generally good. Above 2 or 3 is suspicious (luck, too few trades, or a bug) |
| Monte Carlo | Shuffling the trades like a deck of cards to see how bad a different order could have been |
| Forward test | Running a strategy from today onwards, where nobody knows the answer yet |
Part 1: Make the project folder
Everything lives in one folder. By the end it looks like this:
ai-trading-test/ Setup session runs here (it becomes the referee in Part 4) āāā fable/ Fable 5.2 builds here, locked inside āāā opus/ Opus 5.5 builds here, locked inside āāā hidden/ the hidden year (only the referee opens it) āāā setup/ download script and calibration checks āāā exam/ the referee's code, charts and RESULTS.md
- Create an empty folder called
ai-trading-testsomewhere easy to find, like Documents. - Open Claude Code in that folder.
- Terminal:
cd [PATH TO]/ai-trading-test, thenclaude - Claude desktop app: open the folder in Claude Code
- This is your Setup session. Keep it open, because it becomes the referee in Part 4.
Part 2: Build the fair test (Setup session)
What it does: downloads Bybit's BTCUSDT perpetual 4-hour candles from April 2020 to 1 November 2026 (14,431 candles). It gives the AIs only the candles up to the end of October 2025 (12,240) and hides the last year (2,191) in a separate folder. It writes a backtester that charges 0.075% per side for fees and slippage, writes a strategy template, and locks the fable/ and opus/ folders so neither AI can read outside its own folder or use the internet. Then it proves the setup works, including writing a strategy that cheats on purpose to check it gets caught.
Paste this into the Setup session, exactly as written:
Build a fair trading-strategy build-off between two AIs in this folder, exactly to the spec below. Work on your own, check each step works before moving on, and don't ask me questions. Use only Python with pandas and numpy (pip install them if missing).
1. DATA
- Download Bybit BTCUSDT perpetual (v5 /market/kline, category=linear, interval=240) 4-hour candles: every candle from the one opening 2020-04-01 00:00 UTC up to and including the one opening 2026-11-01 00:00 UTC. That's 14,431 candles. Bybit returns at most 1000 per call, so page through.
- Check there are no gaps or duplicates.
- CSV format: header "ts,open,high,low,close,volume", where ts is the candle open time like "2020-04-01 00:00:00+00:00", sorted oldest first.
- Save the script as setup/download.py.
2. HIDE THE EXAM
- Candles with ts before 2025-11-01 00:00 UTC (12,240 candles) -> fable/data/BTCUSDT_4h_insample.csv
- All 14,431 candles -> hidden/BTCUSDT_4h_full.csv
- No other file may contain any candle from November 2025 or later. Delete raw downloads.
3. BACKTESTER: write fable/backtest.py with exactly these rules
- Constants: COST_PER_SIDE = 0.00055 + 0.00020 (taker fee + slippage), BARS_PER_YEAR = 6 * 365.25, MIN_TRADES = 30, N_CUTS = 8. DATA = data/BTCUSDT_4h_insample.csv next to the script.
- load_data(path): read the CSV with ts as a parsed datetime index; columns open, high, low, close, volume as float.
- load_strategy(path): import the file as a module, return (module, dict(PARAMS)). It must have signal(df, **params).
- clean_signal(sig, index): align to the index, turn inf into NaN, fill NaN with 0, clip to [-1, 1], round.
- lookahead_check(mod, params, df, full_sig): for each cut c in numpy.linspace(int(n*0.3), n-1, N_CUTS).astype(int), recompute clean_signal(mod.signal(df.iloc[:c].copy(), **params)) and compare it to full_sig[:c]. If any value differs, FAIL with "LOOK-AHEAD DETECTED: signal at <time> changes when data after <time> is removed".
- simulate(df, sig, cost_mult=1.0):
- pos = sig.shift(1).fillna(0), so the signal on a candle's close is held from the next candle
- r = close.pct_change().fillna(0)
- turn = pos.diff().abs().fillna(pos.abs())
- net = pos*r - turn*COST_PER_SIDE*cost_mult
- Trades are runs of consecutive equal non-zero pos. Each trade has entry time, exit time, side, number of bars, and ret = prod(1 + pos*r over the run) * (1-c)^2 - 1, using (1-c)^1 instead if the run is still open on the last bar.
- Return (net, pos, trades).
- metrics(net, pos, trades, close):
- equity = cumprod(1+net)
- net return %
- CAGR
- Sharpe = mean(net) / std(net) * sqrt(BARS_PER_YEAR)
- max drawdown % from the equity peak
- number of trades, win rate % (trade ret > 0), profit factor (sum of wins / -sum of losses)
- exposure %, and buy & hold % (last close / first close - 1)
- Round to 2 decimals.
- evaluate(path, df): load the strategy, clean its signal, run lookahead_check, then simulate and metrics. Status is OK if trades >= MIN_TRADES, otherwise FAIL with the reason. Any exception gives ERROR.
- Command line:
- "python backtest.py strategies/s001.py" prints every field.
- "python backtest.py --all" evaluates every strategies/s*.py, sorts by status (OK first) then Sharpe (descending), prints the table, saves results.csv, and prints "<n> OK / <total> total".
- Put this usage at the top of the docstring.
4. TEMPLATE
- Write fable/strategy_template.py:
- NAME = "EMA trend example", FAMILY = "trend following", IDEA = "Long when the fast EMA is above the slow EMA, short when below.", PARAMS = {"fast": 20, "slow": 100}
- signal(): EMA with span=fast and span=slow (adjust=False) on close. Return 1 where fast > slow, -1 where fast < slow, else 0.
- A docstring listing the rules: every setting in PARAMS, return 1/0/-1 per bar, only use data up to the current bar, imports limited to pandas/numpy/math.
- Create an empty fable/strategies/ folder.
5. LOCK EACH AI IN ITS FOLDER
- Write fable/.claude/settings.json:
{"permissions": {"allow": ["Bash(python backtest.py:*)", "Bash(python:*)", "Bash(ls:*)", "Read(./**)", "Edit(./**)", "Write(./**)"], "deny": ["Read(../**)", "Edit(../**)", "Write(../**)", "WebFetch", "WebSearch"]}}
- Then copy the whole fable/ folder, including .claude/, to opus/.
6. EXAM-ROOM SETTINGS
- In this folder, write .claude/settings.json:
{"permissions": {"allow": ["Bash(python:*)", "Bash(ls:*)", "Read(./**)", "Edit(./**)", "Write(./**)", "Read(~/.claude/projects/**)"]}}
7. PROOF CHECKS: these numbers come from the original engine, so all must match
a) In fable/, copy the template to strategies/s001.py and run it. It must show: net return 75.95%, Sharpe 0.47, 143 trades, buy & hold 1622.3%.
b) Write a cheating strategy that uses close.shift(-1). It must be rejected with LOOK-AHEAD DETECTED.
c) In a separate setup/calibration/ folder (never inside fable/ or opus/), write two strategies and run them on the in-sample data with the same backtester:
- Rule A: long when the sum of the signs of the 90-, 180- and 360-candle close-to-close returns is above zero, otherwise flat (missing history counts as 0). Must show +3176.75%, Sharpe 1.66, 184 trades.
- Rule B: EMA 200 of close (span=200, adjust=False). Go long when close > EMA*1.01 and short when close < EMA*0.99. Otherwise keep the previous position, starting flat. Must show +1150.24%, Sharpe 1.06, 137 trades.
d) Delete both test strategies from fable/strategies/ so it's empty, and confirm fable/ and opus/ are byte-identical.
If anything doesn't match, find the difference from the spec, fix it, and re-run. Don't just report it.
FINISH with a short, plain-English summary I can read on camera:
- each file with its date range and number of candles
- a table of every proof check, showing expected vs got and MATCH / NO MATCH
- the cheat rejection message
- one sentence on why the AIs can't see the hidden yearCheck before moving on:
- [ ] Every row in the proof-check table says MATCH
- [ ] The cheat strategy was rejected with LOOK-AHEAD DETECTED
- [ ]
fable/andopus/are confirmed identical - [ ] The in-sample file has 12,240 candles and the full file has 14,431
Part 3: Let the AIs build 100 strategies each
What it does: each AI works as a "quant researcher" and writes 100 different rule-based strategies across trend following, mean reversion, breakout, momentum, volatility, regime filters and combinations (max 20 per family), backtests every one, then picks its top 5 and a champion. Each AI knows it will be marked on the hidden year, so it's told to aim for robustness, not the best number on paper.
You need two new Claude Code sessions, one per folder. Opening each session from inside its own folder is what switches the lock on.
Session A, Fable:
- New terminal:
cd [PATH TO]/ai-trading-test/fable, thenclaude - Switch the model to Fable 5.2 (type
/model) - Paste the prompt below
Session B, Opus:
- Second terminal:
cd [PATH TO]/ai-trading-test/opus, thenclaude - Switch the model to Opus 5.5 (type
/model) - Paste the same prompt
Both get the exact same text:
You are a quant researcher. Your job: find trading strategies for BTCUSDT perpetual futures on the 4-hour timeframe that will still work on data you have never seen. What's in this folder: - data/BTCUSDT_4h_insample.csv : the only price data you get (Apr 2020 - Oct 2025) - backtest.py : run `python backtest.py strategies/s001.py` for one strategy or `python backtest.py --all` for every strategy. It reports net return, Sharpe, max drawdown, win rate, profit factor and trade count. Fees and slippage (0.075% per side) are already included. - strategy_template.py : copy this format exactly. The task: 1. Create 100 distinct rule-based strategies, strategies/s001.py to s100.py. Each file defines signal(df) returning -1 (short), 0 (flat) or 1 (long) per bar, with all parameters as named defaults at the top of the file. 2. Spread them across families: trend following, mean reversion, breakout, momentum, volatility, regime filters, and combinations. No more than 20 from any single family. 3. Rules: only use data up to the current bar (no look-ahead). Every strategy must take at least 30 trades. No machine learning models, just explicit rules. 4. Use backtest.py as much as you want to test and improve your ideas. 5. Keep strategies/index.csv up to date with columns: id, name, family, one-line idea. Important: after you finish, all 100 strategies will be scored on HIDDEN data from after Oct 2025 that you cannot see. Strategies that are curve-fitted to the in-sample data will fail. Optimise for robustness, not for the best in-sample number. When you're done, write FINAL.md containing: - your top 5 strategy ids, ranked, with why you trust each to hold up out of sample - your single champion pick and the one biggest risk to it - which ideas you tried and abandoned, and why Work autonomously until all 100 strategies run cleanly with `python backtest.py --all`. Don't ask me questions. Print a one-line progress update after every 20 strategies, and finish by printing your top 5 and champion in a small table.
While they work:
- Don't help them. No hints, no extra data, no answers to questions.
- If either one asks to read outside its folder or use the web, deny it. That's the lock doing its job.
- If one stops early, type:
Keep going until all 100 strategies run cleanly with python backtest.py --all. Don't ask me questions. - In the video, Fable finished in about 13 minutes and Opus in about 17. Yours may differ.
When they're done, each folder has strategies/s001.py to s100.py, an index.csv and a FINAL.md. Write down each AI's champion and the biggest risk it named. That's its prediction, made before the exam.
Testing one model only? Run just one of the two sessions. In Part 4, add this line at the very top of the prompt: Only [fable/ or opus/] was used this time. Skip the other folder everywhere.Part 4: Unlock the hidden year and mark the exam (Setup session)
What it does: the Setup session becomes the referee. It first proves nobody cheated: the files are identical, no strategy opens files or touches the internet, and it reads both build sessions' logs looking for any attempt to reach the hidden data, the web or a date after October 2025. Then it unlocks the hidden year, runs every strategy on it, runs the five tests on each champion, proof-checks its own maths against the original engine, draws the charts and writes a plain-English report.
Go back to the Setup session (the one in ai-trading-test/) and paste:
Two AIs each built 100 trading strategies in fable/ and opus/, using only BTCUSDT 4h data before 2025-11-01. Each folder has strategies/, strategies/index.csv and FINAL.md with that AI's champion. hidden/BTCUSDT_4h_full.csv has all 14,431 candles. The HIDDEN period is ts >= 2025-11-01 00:00 UTC, which neither AI ever saw. Score them exactly to the spec below. Don't edit anything in fable/ or opus/, and don't ask me questions. Put all code in exam/ and all outputs in exam/out/. STEP 1, PROVE NOBODY CHEATED (report each as CLEAN or a problem) - fable/backtest.py and opus/backtest.py are byte-identical, and so are their in-sample CSVs (12,240 candles, last one 2025-10-31 20:00). - No strategy file mentions "hidden", opens files, or uses the network. - Session logs: Claude Code stores each session under ~/.claude/projects/<folder>, where <folder> is the session's full working-directory path with every character that isn't a letter or digit replaced by "-". Work out the folders for fable/ and opus/. In every *.jsonl there, look only at records with type "assistant" and their tool_use blocks. Flag any of: "hidden", "BTCUSDT_4h_full", "../", WebFetch, WebSearch, any mcp__ tool, bybit/binance/coingecko/yfinance/ccxt, or any date in November 2025 or later. STEP 2, THE ENGINE - Import fable/backtest.py, so it's the exact same fees, next-candle rule and metrics. - For each strategy, run it on the FULL data: sig = clean_signal(signal(full, **PARAMS)), then simulate. Repeat lookahead_check on the full data. - "In-sample" = metrics over bars before 2025-11-01. "Hidden" = metrics over bars from 2025-11-01 on, with trades counted by entry time. A position open on 31 October carries over. - Gate each strategy with evaluate() on the in-sample data only. Only OK strategies are scored. - The champion is the first sNNN after the word "champion" in each FINAL.md. STEP 3, THE 5 TESTS, for each AI TEST 1, NEW DATA: - how many strategies have hidden net return > 0, and how many beat buy & hold - median in-sample Sharpe vs median hidden Sharpe - Spearman rank correlation of in-sample Sharpe vs hidden Sharpe - the champion's in-sample CAGR vs hidden return, and its hidden rank by Sharpe (1 = best) TEST 2, TWEAK THE SETTINGS: for the champion, multiply each numeric PARAM by 0.8 and by 1.2, one at a time (round ints, skip a change that leaves the value the same), and list each version's hidden return and Sharpe. How many stayed profitable? TEST 3, HIGHER FEES: the champion's hidden return at cost_mult 0, 1, 2 and 3. TEST 4, WORST CASE: numpy default_rng(42). Take the champion's hidden trade returns and draw 1,000 samples with replacement, each the same length. Compound each one. Report the % that end below zero, the median max drawdown and the 5th-percentile (worst 5%) max drawdown. TEST 5, LUCK CHECK: numpy default_rng(42). - For every strategy, take its hidden trades. Real score = sum of log(1+ret). - Make 1,000 random twins. For each trade, take L = min(bars, n-2), pick start s = rng.integers(1, n-L), and use gross = prod(1 + side * r[s:s+L]) * (1-COST_PER_SIDE)^2, where r = hidden close pct_change and n = number of hidden bars. Twin score = sum of log(gross). - Report the % of twins the real score beats. Pass = 95% or more. - How many strategies per AI passed, and both champions' %. THE ONE IT SHOULD HAVE PICKED: each AI's best strategy on hidden Sharpe (with at least 5 hidden trades). Show its hidden return and max drawdown, and where it ranked in that AI's in-sample list. STEP 4, PROOF CHECK: run these two rules on the full data and report the hidden-period result. They come from the original engine: - Rule A: long when the sum of the signs of the 90-, 180- and 360-candle returns is above zero, otherwise flat. Must give +8.07% and 43 trades. - Rule B: EMA200 band, long above EMA*1.01 and short below EMA*0.99, otherwise hold. Must give +26.15% and 26 trades. - Buy & hold over the hidden period must be -29.44%. - If anything doesn't match, fix your code until it does. STEP 5, CHARTS (PNG in exam/out/; dark background, Fable #F59E0B, Opus #8B5CF6, BTC grey dashed): - spaghetti_fable.png and spaghetti_opus.png: every strategy's hidden-period equity from $10,000, champion highlighted, buy & hold dashed - full_history.png: both champions + buy & hold from April 2020, $10,000 start, log scale, hidden period shaded purple STEP 6, REPORT - Write exam/RESULTS.md in plain English, for non-quants: a PASS/FAIL scoreboard for each test and each AI, who won and why, and the strategy each AI should have picked.
Check before moving on:
- [ ] Cheating checks come back clean for both AIs
- [ ] Rule A gives +8.07% / 43 trades, Rule B gives +26.15% / 26 trades, buy and hold gives -29.44%
- [ ]
exam/RESULTS.mdhas the scoreboard, andexam/out/has the three charts
Optional: drag RESULTS.md and the three charts into a Claude chat and ask for "a one-page visual summary I can scroll through". That's how Miles made the results page in the video.
Part 5: Ask each AI how its pick held up
Go back to the Fable session and the Opus session and paste this into each:
Your strategies have now been scored on the hidden data (1 Nov 2025 to 1 Nov 2026). Read ../exam/RESULTS.md, and only that file outside your folder. Be honest and keep it short: did your champion hold up? Why or why not? Which strategy should you have picked instead, and what would you do differently?
The build folders are locked, so Claude Code may ask permission to read that one file. Approve it. If the lock blocks it completely, copy exam/RESULTS.md into the fable/ and opus/ folders (the build is finished, so this can't help them cheat) and change ../exam/RESULTS.md to RESULTS.md in the prompt.
In the video, Fable called its pick's result "survival, not demonstrated skill". Opus admitted "my champion didn't hold up" and said that picking one strategy "is close to a coin flip".
Part 6: How to read the results
The three numbers to check on any backtest
- Max drawdown. The worst drop from a high to a low. Most traders and funds have a max drawdown limit, and a big one forces smaller position sizes, so a strategy with a higher return and a huge drawdown can end up making you less in practice.
- Sharpe ratio. Return compared with how bumpy the ride was. Above 1 is generally good. Above 2 or 3 is a warning sign: in the video, one Opus strategy scored 2.42 on the hidden year, but it only made four trades.
- Trade count. Too few trades and the numbers mean very little. Aim for at least 30.
The five tests
| Test | What it asks | Pass mark |
|---|---|---|
| 1. New data | Did it make money on data it never saw? | Made money in the hidden year |
| 2. Tweak the settings | Does it still work if each setting moves 20% up or down? Like a cake recipe: if it only works with exactly 200 grams of flour, you probably got lucky | Every version stays profitable |
| 3. Higher fees | Does it survive when real fills cost more than the backtest assumed? | Still positive at double fees |
| 4. Worst case | Shuffle its trades 1,000 times. How often does it end up losing? | Loses in under 10% of shuffles |
| 5. Luck check | Give it 1,000 "random twins" with the same number of trades, same direction, at random times. Does it beat them? | Beats 95% or more |
Picking a strategy
- Don't pick the best-looking backtest. In the video it came 140th out of 200 on the hidden year.
- Look at the one each AI "should have picked" in
RESULTS.md, but remember nothing on paper would have pointed you to it. - Think basket, not champion. Both AIs ended up saying the same thing: a handful of different strategies is safer than betting on one.
- Anything that passes Tests 1 to 3 is a candidate for a TradingView backtest (Part 7) and a forward test (Part 9). Nothing in the video passed all five, so nothing has proven a real edge yet.
Part 7: Turn a strategy into Pine Script and test it in TradingView
Pick the strategy you want to look at, for example your best scorer in Part 6. Then paste this into the Setup session, filling in the brackets:
Turn [fable or opus]/strategies/[sNNN].py into a TradingView Pine Script v6 strategy I can paste into the Pine Editor. Match backtest.py as closely as TradingView allows: - The signal is worked out on each 4-hour candle's close: 1 = long, -1 = short, 0 = flat. It flips straight from long to short when the signal does. - Fill on the close of the signal candle (process_orders_on_close = true), to match "the signal on a candle's close is held from the next candle". - Commission 0.075% per side, which covers the backtest's fee plus slippage. - 100% of equity per trade, no leverage, no pyramiding. - Every setting in PARAMS becomes an input with the same default. - Only data up to the current candle: no future bars, no lookahead in request.security. - It must be a strategy(), not an indicator(), so it can send orders to Bybit later. Save it as pine/[sNNN].pine. Then tell me in plain English: which chart to load it on, what the strategy does, the Python backtest numbers for the same strategy so I can compare, and what could make TradingView's numbers differ.
In TradingView:
- Open a chart of Bybit's Bitcoin perpetual (search
BTCUSDT.Pand pick the Bybit one) on the 4-hour timeframe. - Open the Pine Editor (Miles clicks the small Pine icon on the chart screen).
- Paste the script, click Save, then Add to chart.
- Open the Strategy Tester at the bottom of the chart.
- Look at the net profit, the max drawdown and the full list of trades. Change the date range to see how it did in different periods.
- Under the strategy's settings, change Initial capital to see it with $10,000, $100,000 or whatever you'd actually use.
- Compare the numbers with the Python backtest. Small differences are normal (data feed, fill timing). Big ones mean the conversion is off, so ask Claude to compare the two trade lists.
Refining it: you can go back and forth with Claude to improve the strategy. Just remember the lesson of the video: every tweak you make by looking at the same chart fits the strategy to that chart. After each round of changes, run the five tests again (the Bonus prompt below does this) before trusting the new version.
Part 8: Connect it to Bybit
This makes it a working trading bot: TradingView watches the chart, and when your strategy fires, it sends an alert to Bybit, which places the order.
In the video, Miles used Opus's s010 here only to show how the setup works, not as a recommendation. Use whichever strategy you've tested.
Step 1: Choose how you want to run it
Bybit account: Unlock $30K+ in welcome rewards š https://partner.bybit.com/b/166453
Pick one of these, safest first:
- No exchange at all (zero risk). Skip the rest of Part 8. Keep the strategy on your TradingView chart (Part 7). The Strategy Tester adds every new trade as each 4-hour candle closes, so it becomes a live paper record. Add an alert with an app notification if you want to see each signal as it happens. Nothing gets sent to Bybit and no webhook is needed.
- Bybit Demo Trading (pretend money). Switch to Demo Trading from your profile menu on bybit.com and look for Tools > Webhook Signal Trading on the BTCUSDT perpetual page. Bybit's help article doesn't say whether the tool works in demo, so if you can't find it there, go back to option 1 or use option 3.
- A small real sub-account (what Miles describes in the video). Create a sub-account, move in a small amount you can afford to lose, and run this bot only in that sub-account. Your main account stays untouched.
Step 2: Prepare the BTCUSDT perpetual
- Make sure the funds are in your Unified Trading Account.
- Open the BTCUSDT perpetual trading page.
- Set the position mode to One-Way Mode.
- Set leverage to 1x. The backtest never used leverage, so anything higher is a different, riskier strategy.
Step 3: Create the webhook on Bybit
- In the order area of the BTCUSDT page, click Tools, then Webhook Signal Trading.
- Click Create Now, read the overview, then click I've confirmed the above.
- Fill in the form:
- Trading pair: BTCUSDT (it must match the chart your strategy runs on)
- Position mode: One-Way Mode
- Signal name:
[e.g. s100 forward test]
- Click Create Webhook. Bybit now shows your Webhook URL and a message template.
Keep the webhook URL private. Anyone who has it can send orders to your account. Don't paste it into a chat, a screenshot or a Discord message, and that includes chats with AI.
Step 4: Load the strategy on TradingView
- From Bybit, click through to run the strategy on TradingView, or open TradingView yourself on Bybit's
BTCUSDT.P, 4-hour chart. - Open the Strategy Tester and load your strategy from Part 7.
- Open the strategy's Properties:
- Initial capital: what's actually in your Bybit (sub-)account
- Order size: a fixed number of contracts,
[ORDER SIZE in BTC], not "% of equity". With "% of equity", TradingView sizes live orders from the backtest's paper profits, not from your real balance.
Step 5: Create the alert
- Click the alert icon in the Strategy Tester.
- Message box: paste Bybit's message template. Keep the quantity as
{{strategy.order.contracts}}so that flipping from long to short works. - Notifications tab: tick Webhook URL and paste your Bybit webhook URL.
- Check the alert's expiration date. An expired alert silently switches your bot off.
- Click Create.
Step 6: Switch it on
- Match the starting position first. Look at the Strategy Tester: is the strategy in a trade right now? If it's flat, you're fine. If it's long or short, Bybit doesn't know that, so the first signal will leave your account in the wrong position (for example, a "close the long" signal would open a short instead). Either wait until the strategy goes flat, or open the same position by hand on Bybit, same direction and same size, before you switch the bot on.
- Back on Bybit, choose Market as the order type.
- Leave take-profit and stop-loss off, because the backtest didn't use them. Exits come from the strategy.
- Click Run the webhook.
It's live now, but it won't trade straight away. It waits for the strategy's next signal. When that comes, TradingView sends the alert, Bybit places the order, and the position shows up on your Bybit page (you also get a push notification).
Step 7: Watch, pause or stop it
- Tools > Webhook on Bybit shows the signal name, each trade and the realized P&L.
- Pause stops it for now. Terminate ends it.
- Bybit switches it off automatically after 10 failed orders in a row, so check on it.
Bybit's webhook is the route Miles prefers because it's the easiest. Other signal-bot services can trigger trades too.
Part 9: Forward test it, slowly
A forward test runs from today, so nobody knows the answer yet. Not you, not Miles, and not an AI that might remember some of the past from its training (Fable admitted it had some knowledge of Bitcoin prices after October 2025, and said it didn't use it). It's the one test that can't be faked.
- Run it on paper, demo or a tiny sub-account for at least a few months. Market conditions (volatility, volume) change, even compared with last year.
- Wait for at least 30 trades before judging it. The picks in the video made 33 and 36 trades in a year, so a fair forward test of a strategy like these takes about a year.
- Start small: 1, 2 or 3% of the most you'd be willing to risk.
- Scale up slowly, and only while it keeps performing the way the tests said it would.
- Consider a basket. Running a few different strategies small is safer than betting on one champion.
Expect live results to come in a bit worse than the backtest. The backtest charges fees and slippage, but it doesn't include funding: on perpetual futures you pay or receive a funding fee several times a day while you hold a position. Real fills can also be worse than the 0.02% slippage the backtest assumed.
Bonus: Run the five tests on any strategy
Got a strategy from somewhere else, or one you've been refining? Paste this into Claude Code before you put money behind it:
I have a trading strategy: [FILE PATH, OR DESCRIBE THE RULES]. Before I risk money on it, run the five tests from the Fable vs Opus video on it. Use Python with pandas and numpy. Only ask me a question if something essential is missing. Data: [MARKET, e.g. Bybit BTCUSDT perpetual] on the [TIMEFRAME, e.g. 4h] timeframe. Download it from the exchange's public API. Everything before [SPLIT DATE] is the backtest; everything from [SPLIT DATE] onwards is the new data. If the strategy was built or tuned on any data after [SPLIT DATE], tell me, because then Test 1 means nothing. Rules for every test: the signal is taken on a candle's close and held from the next candle, [0.075]% cost per side, and no look-ahead (prove it: recompute the signal with later data cut off and check nothing earlier changes). TEST 1, NEW DATA: return, Sharpe, max drawdown and trade count on the new data, next to buy & hold. Pass = it made money. TEST 2, TWEAK THE SETTINGS: multiply each numeric setting by 0.8 and by 1.2, one at a time. Pass = every version stays profitable on the new data. TEST 3, HIGHER FEES: new-data return at 0x, 1x, 2x and 3x the cost. Pass = still positive at 2x. TEST 4, WORST CASE: numpy default_rng(42). Resample the new-data trade returns with replacement 1,000 times, each the same length, and compound each. Pass = under 10% end below zero. Also give the median and worst-5% max drawdown. TEST 5, LUCK CHECK: numpy default_rng(42). Make 1,000 random twins with the same number of trades, same directions and same lengths, at random start times, paying the same costs. Pass = the real strategy beats 95% or more of them. Finish with a plain-English PASS/FAIL scoreboard, the trade count (warn me if it's under 30), and one sentence on whether it's ready for a forward test.
Troubleshooting
A proof check says NO MATCH. The prompt tells Claude to find the difference and fix it, so let it keep going. If it still won't match, the download is usually incomplete: ask it to re-run setup/download.py and check for exactly 14,431 candles with no gaps.
The download fails. Bybit's API may be blocked where you live. The proof-check numbers only match Bybit's data, so another exchange won't give you the same results.
Can I use newer data? Yes, but change every date in Parts 2 and 4 together, and delete the "Must show..." and "Must give..." numbers, because they only apply to the video's dates. You lose the check that your setup matches Miles's engine.
A build session keeps asking questions or stops early. Type: Keep going until all 100 strategies run cleanly with python backtest.py --all. Don't ask me questions.
A build session asks to read outside its folder or use the web. Deny it. That's the lock working.
Lots of permission prompts to run Python. On some computers the command is python3 rather than python, and the folder's settings only pre-approve python. It's safe to approve these, as long as the command only runs Python inside that folder.
You hit your Claude usage limit mid-build. Building and testing 100 strategies is a big job. Wait for your limit to reset, then type continue in the same session. It picks up from the files it has already written.
The referee can't find the session logs. This happens if the builds ran somewhere other than this computer. The other cheating checks still run.
TradingView's numbers differ from Python's. Small differences are normal. For big ones, ask Claude to compare the two trade lists and find where they split.
The bot isn't trading. Check, in this order: the strategy simply hasn't signalled yet; your TradingView plan is paid and two-factor authentication is on; the alert hasn't expired; the script is a strategy, not an indicator; the trading pair matches on both sides; the position mode is One-Way; there's enough balance in the Unified Trading Account. Bybit's Tools > Webhook page shows the reason for each failed order.
*From Miles Deutscher Finance's Fable 5.2 vs Opus 5.5 trading video. For education only, not financial advice. Past results, on paper or on hidden data, don't predict future results.*