The Claude Quant PlaybookDownload ebookDownload ebook

Free playbook · 7 steps · 7 equations · any market

Grok Bot watches. Claude Code tests. Math decides.

A trading routine for two AIs, where an equation makes every call. Set your market and your risk once. Each step then opens in the right app with your numbers already filled in.

Build a trading system with Claude.Download ebook

Grok Bot watches

The one that stays awake.

It runs on a schedule in the cloud while your laptop is closed, reads X and the news, and messages you. It proposes. You approve.

Claude Code tests

The one that proves it.

It works in a folder on your computer. It writes your rules, runs the backtest and grades your trades, as files you can open and run again.

Math decides

The one neither can argue with.

Every step ends in a number with a pass mark. The AIs do the sums and show their working. You read the verdict.

Set your desk once

Every prompt on this page fills itself in from these. Nothing leaves your browser.

Most you lose on one trade
$100
You stop for the day at
−$300
3 full losses in a row
The desk halts at
−$1,000
10 full losses in a row
To climb back from there
+11.1%
loss ÷ (1 − loss)

Now give both AIs the same desk card

Grok BotDesk card
Remember this as my permanent desk card. Market: US stocks & ETFs. Style: swing (holding days to weeks). Watchlist: SPY, QQQ, AAPL, MSFT, NVDA. Account: $10,000. Market hours: 09:30 to 16:00 New York time, Monday to Friday. Rules you never break: (1) Max loss on one trade: 1% of the account, $100. (2) Daily stop: after losing 3% in a day, $300, no new trades that day. (3) Max drawdown: at 10% below the account's peak, $1,000, everything halts until I type RESTART. (4) Paper trading only: use a free paper account such as Alpaca paper trading. Never place, change or cancel an order or move money without my approval each time. (5) If a price is missing or old, say so. Never guess. Explain in simple English and show the formula and numbers for every calculation. Reply with my three risk numbers so I know you saved them.
Claude CodeDesk card and folder
Set up my trading desk folder.

1. Create a folder called trading-desk (if it does not exist) with these folders inside: rules, tests, tools, journal, reviews.
2. Save the desk card below as trading-desk/CLAUDE.md, word for word.
3. Reply with my three risk numbers so I know you saved them. Do nothing else yet.

MY TRADING DESK CARD
Market: US stocks & ETFs. Style: swing (holding days to weeks). Watchlist: SPY, QQQ, AAPL, MSFT, NVDA.
Account: $10,000. Market hours: 09:30 to 16:00 New York time, Monday to Friday.
Free history to test on: daily prices from Stooq or Yahoo Finance.

Rules you never break:
1. Max loss on one trade: 1% of the account = $100.
2. Daily stop: after losing 3% in one day ($300), no new trades that day.
3. Max drawdown: at 10% below the account's peak (a loss of $1,000), everything halts until I restart it.
4. Paper trading only: use a free paper account such as Alpaca paper trading. Never place, change or cancel a real order, and never move money.
5. If data is missing or old, say so. Never guess a price or invent a result.

How to talk to me: simple English. Show the formula and the numbers for every calculation. Finish the whole task before you reply.

The buttons open the app on this device and put the text in the message box. You read it and press send. Grok Bot links go to your primary Bot. Claude Code links work on a computer, after your first session there. If nothing opens, use Copy.

Step 1: Find

Is this idea likely to be real?

Grok Bot

Every evening Grok Bot reads X, the news and filings for your watchlist, and brings back at most five ideas. Each one must come with a reason it should work.

Then Pick one idea card and copy it. You paste it into step 2.

The math that decides Bayes' theorem

the share of ideas that are real
the share of real ideas your test catches
the share of fake ideas that pass anyway

Most ideas are noise. So most ideas that pass a test are still noise, unless the test is strict.

Say 1 idea in 20 is real. Run 400 ideas through a loose test: 16 of the 20 real ones pass, and so do 19 of the 380 fakes. A pass is real only 46% of the time. Demand and, if the test still catches those 16, fewer than 1 fake gets through: 97%.

  • GOThe idea has a reason to exist (someone on the other side who keeps paying) and data you can get to test it.
  • NO-GOIt only looks good on a chart, or you cannot say who loses.

Try your own numbers

Grok BotIdea scout

Sets up a nightly routine and runs it once so you see the format.

Job: idea scout for my trading desk. Use my desk card. Every evening at 20:00 my time, search X, the news and official filings or announcements for my market and my watchlist. Bring me at most 5 idea cards. Each card has 5 lines: (1) the idea in one sentence; (2) why it should exist: who is on the other side of the trade and why they keep paying; (3) the exact data needed to test it; (4) what result would prove it wrong; (5) sources with links and dates. Drop any idea that has no reason to exist. Label rumours as rumours. Do not predict prices, do not rank by hype, and never place a trade. Save this as a routine, then run it once now so I can see the format.

More for this stepWake up to a ranked watchlistClaude overnight jobNews impact scorerClaude skill39 news and sentiment botsGrok Bots

Step 2: Rules

Do I make money on average?

Claude Code

Claude Code turns one idea into exact rules: entry, exit, stop and costs, written so that two people would take the same trades.

Then Nothing to carry. The rules are saved in trading-desk/rules/strategy.md for step 3.

The math that decides Expectancy

your win rate
average win and average loss
cost per trade: fees, spread, slippage

What one trade is worth on average, after costs. Everything is counted in R, where 1R is what you risk on one trade.

Win 40% of the time, make 2R when right, lose 1R when wrong, pay 0.05R in costs: a trade. You are wrong 6 times in 10 and still ahead. Break-even here is a 35% win rate.

  • GOEvery rule is a number or a formula, and E is above zero after costs.
  • NO-GOA rule says strong, weak or feels. There is no stop. Or E is zero or below.

Try your own numbers

Claude CodeRule writer

Paste one idea card where it says to, or describe a setup you already trade.

You are the rule writer on my trading desk. Work only inside the trading-desk folder and read trading-desk/CLAUDE.md first.

Turn this idea into exact rules I can test:
[PASTE ONE IDEA CARD FROM STEP 1, OR DESCRIBE YOUR SETUP IN YOUR OWN WORDS]

Write trading-desk/rules/strategy.md with:
1. Market and timeframe.
2. Entry: the exact conditions, using only information available at that moment.
3. Exit: profit target, stop loss and time stop, each as a number or a formula.
4. When it stays out: news days, thin volume, wide spreads, anything else that breaks it.
5. Costs to assume on every trade in my market: fees, spread and slippage. If you do not know my broker's fees, ask me.
6. The expectancy check in R, where 1R is my max loss on one trade: E = p × W − (1 − p) × L − c. Show the win rate the plan needs to break even: p* = (L + c) / (W + L).

Rules for you:
- If two traders could read a rule and take different trades, rewrite it until they could not.
- Keep the numbers I am allowed to tune as few as possible, and list them.
- No "strong", "weak" or "looks like" without a number behind it.
- Do not write code and do not test anything yet.

Finish the whole file, then give me a one-screen summary in plain words and tell me if E is above zero.

More for this stepStrategy spec writerClaude skillTurn a trading book into rules you can testClaude overnight jobWrite your full trading rulebookClaude overnight job

Step 3: Test

Skill or luck?

Claude Code

Claude Code backtests the rules on data they have never seen, with costs taken off, and tries to prove the strategy does not work.

Then Nothing to carry. The verdict is the first line of trading-desk/tests/report.md.

The math that decides The t-statistic

average result per trade
how much results swing (standard deviation)
number of trades
how many ideas or versions you tried

Your average, measured against its own noise. More trades shrink the noise. Trying more ideas grows the luck.

The +0.15R strategy from step 2 swings by 1.47R a trade. After 100 trades , which luck explains easily. It takes about 865 trades to reach . And if you try 20 ideas, the chance that at least one passes a 5% test by luck is 64%.

  • GOt is 3 or more on unseen data, after costs.
  • WAITt is between 2 and 3. Paper trade it and collect more trades.
  • NO-GOt is below 2, or the edge is gone once costs go in.

Try your own numbers

Claude CodeTester

The longest job on the desk. Start it and come back.

You are the tester on my trading desk. Work only inside the trading-desk folder. Read CLAUDE.md and rules/strategy.md. Your job is to try to prove this strategy does NOT work.

1. Before you start, work out how many trades the test needs: n ≥ (3 × s / x̄)², using the s and x̄ the plan implies. Then get enough history for my market to reach that, including at least one period when this market fell hard. Tell me the source. If you cannot get the data, stop and ask me for a file.
2. Write the backtest in Python in tests/. Use only information that existed at each moment (no look-ahead). Keep names that later died or were delisted if the data has them. Take the costs in strategy.md off every trade.
3. Hold back the most recent third of the data. Build and tune only on the older part. Freeze the rules, then run the held-back third once.
4. Write tests/report.md for the held-back third: number of trades n, average result per trade in R (x̄), standard deviation in R (s), t = (x̄ / s) × √n, win rate, average win, average loss, max drawdown. Save the equity curve as tests/equity.png.
5. Count every version you tried, N. Print 1 − 0.95^N: the chance that at least one version passes a 5% test by luck alone.
6. The first line of the report is the verdict: GO if t ≥ 3. WAIT if t is between 2 and 3 (paper trade to collect more trades). NO-GO if t is below 2, or the average is at or below zero after costs.

Never change a rule after you have seen the held-back third. If the verdict is NO-GO, say so plainly: most ideas should fail here. Do not place any trades. Finish the whole job before you reply.

More for this stepBacktest auditorClaude skillBacktest labClaude agent teamBacktest Forensics LabGrok Bot

Step 4: Size

How much on one trade?

Claude Code

Claude Code writes your risk rules and a small calculator. You give it an entry and a stop, it gives you the size.

Then Copy trading-desk/rules/strategy.md and rules/risk.md. You paste both into Grok Bot in step 5.

The math that decides Position size, with a Kelly ceiling

your account
the share of it you risk on one trade
the Kelly fraction: the risk that grows an account fastest, in theory
average win ÷ average loss

Decide the loss first. The distance to your stop then sets the size. Kelly is the speed limit: stay under half of it.

Account 10,000, risk 1%, so 100 on the line. Entry 250, stop 240: each unit risks 10, so you buy 10 units. Kelly for a 40% win rate at 2 to 1 is . Half of that is 5%, so 1% is well inside.

  • GORisk per trade is at or below half Kelly, and the position fits inside the account.
  • NO-GOKelly is zero or negative: there is no edge, so the size is zero. Or there is no stop.

Try your own numbers

Claude CodeRisk manager

Writes risk.md and a size calculator you can run before every trade.

You are the risk manager on my trading desk. Work only inside the trading-desk folder. Read CLAUDE.md, rules/strategy.md and tests/report.md.

Write rules/risk.md, short enough to paste into a chat:
1. Position size for every trade: units = floor( (account × risk %) ÷ |entry − stop| ). Work one example with my account and a typical stop for this strategy.
2. Kelly check, using the held-back results: f* = p − (1 − p) ÷ b, where p is the win rate and b is average win ÷ average loss. If my risk % is above half of f*, lower it and tell me. If f* is zero or negative there is no edge: the size is zero and the verdict is NO-GO.
3. My limits, copied from the desk card: max loss per trade, daily stop, max drawdown. Add a cap on open positions and on total risk open at one time.
4. When to trade smaller: if today's swing is more than twice its 20-day average, halve the size.
5. Gaps: a price can jump straight past a stop, so the real loss can be bigger than planned. Say how this strategy handles that.

Then build tools/size.py: I give it an entry and a stop, it prints the units, the position value and the loss at the stop. Test it on 3 cases, including a stop so tight that the position would be bigger than my account (it must cap the size).

Finish everything, then show me risk.md.

More for this stepPosition sizerClaude skillA position size calculatorClaude buildRisk ControllerGrok Bot

Step 5: Watch

Is this move unusual?

Grok Bot

Grok Bot checks your watchlist on a schedule. It messages you only when a rule is met or a move is far outside normal, with the entry, stop and size already worked out.

Then Nothing to carry. Alerts arrive in your Grok Bot chat.

The math that decides The z-score

today's move
its average move
its normal daily swing (20-day standard deviation)

How many normal-sized swings away from normal today is. Under 2 is ordinary noise.

A stock that normally swings 1.2% a day falls 3.6%: . On a bell curve that is about 1 day in 370. Real markets have fatter tails, so it happens more often. Treat it as a reason to look, never as a signal by itself.

  • GOA rule from step 2 is fully met, the size comes from step 4, and you approve it.
  • WAITz is 2 or more but no rule is met. Read why. Do nothing.
  • NO-GONo rule is met, or the price is old.

Try your own numbers

Grok BotLoad my rules

Copy this, then paste your strategy.md and risk.md under it. Too long for a one-tap link.

Here are my trading rules from Claude Code. Remember them as the only rules you may alert on, and tell me in three lines what would make you alert me. If any rule is not exact enough to check, ask me now. [PASTE rules/strategy.md AND rules/risk.md HERE]
Grok BotMarket watcher

Each check uses some of your Grok Bot usage, so the schedule follows your trading style.

Job: market watcher for my desk. Use my desk card and my saved rules. During market hours, check my watchlist twice a day: 30 minutes after the open and 30 minutes before the close. For each symbol work out z = (today's move − its 20-day average move) ÷ its 20-day standard deviation. Message me only when a saved rule is fully met, or when z is 2 or more in either direction. Each alert has 6 lines: (1) symbol, price, source and time of the price; (2) z, and what a normal day looks like; (3) the likely reason from X and the news, with links, or 'no reason found'; (4) the rule that was met, if any; (5) entry, stop and size, from units = (account × risk %) ÷ |entry − stop|; (6) what would cancel the idea. Never place an order: propose it and wait for my approval. If you cannot get a current price, say so and send no alert. Save this as a routine.

More for this stepA watchlist with price alertsClaude buildMarket regime detectorClaude skill17 technical setup botsGrok Bots

Step 6: Stop

When do I stop?

Grok Bot

Grok Bot keeps the journal, tracks today's loss and the drawdown from your peak, and tells you the moment a limit is hit.

Then Nothing to carry. The journal lives on the Bot's computer until step 7.

The math that decides Drawdown maths

drawdown: your loss from the peak
risk per trade
losses in a row

The deeper the hole, the steeper the climb out. So the stop is set before the hole gets deep.

Lose 10% and you need +11% to get back. Lose 50% and you need +100%. Ten losses in a row cost 9.6% at 1% risk, and 40% at 5% risk. At a 40% win rate, a run of ten straight losses turns up within 1,000 trades about 9 times in 10.

  • GOToday's loss is under your daily stop and drawdown is under your limit.
  • NO-GODaily stop hit: no new trades today. Max drawdown hit: everything halts until you restart it.

Try your own numbers

Grok BotStop keeper

Keeps the journal that step 7 grades.

Job: stop keeper for my desk. Use my desk card limits. Keep a journal at /workspace/desk/journal.csv with one row for every paper or real trade I tell you about or you can see: date, symbol, side, entry, stop, exit, units, result in money and in R. After every trade, and at the end of every trading day, work out today's result and the drawdown from the account's peak. If today's loss reaches my daily stop, message me 'DAILY STOP: no new trades today' and propose nothing until tomorrow. If drawdown reaches my max drawdown, message me 'DESK HALTED', list every open position, and propose nothing until I type RESTART. Each time, show the maths: gain needed to recover = loss ÷ (1 − loss). You never open or close a position yourself. Save this as a routine, and add an Ask first rule for anything that touches an order.

More for this stepDrawdown doctorClaude skillA drawdown recovery calculatorClaude build20 risk and journal botsGrok Bots

Step 7: Review

Is it still working?

Grok BotClaude Code

Once a week Grok Bot hands over the journal, and Claude Code grades it against the backtest: keep, fix or stop.

Then A FIX goes back to step 2 as one proposed change. A KEEP means you do nothing, which is the hard part.

The math that decides Confidence interval

your live average per trade
how much results swing
live trades so far

Your live average, give or take its noise. While the backtest's number sits inside that range, nothing is broken.

The test said +0.15R. After 30 live trades you average −0.05R. The range is −0.58R to +0.48R, so +0.15R is well inside: leave the rules alone. After 400 trades the range is −0.19R to +0.09R. Now the gap is real.

  • KEEPThe backtest average is inside your live range. Change nothing.
  • FIXIt is outside on the low side. Make one change and send it back through steps 2 to 4.
  • STOPMax drawdown was hit, or more trades broke the rules than followed them.

Try your own numbers

Grok BotWeekly hand-over

Sends you the journal file every Saturday. Save it as trading-desk/journal/journal.csv.

Job: weekly hand-over for my desk. Every Saturday at 10:00 my time, send me /workspace/desk/journal.csv as a file, plus 5 lines: trades this week, result in R, biggest loss, any rule I broke, any stop I moved. Do not judge the strategy and do not suggest changes: the review happens in Claude Code. Save this as a routine.
Claude CodeReviewer

Run it after you have saved the newest journal file.

You are the reviewer on my trading desk. Work only inside the trading-desk folder. Read CLAUDE.md, rules/strategy.md, rules/risk.md, tests/report.md and journal/journal.csv (my paper or live trades; I have just saved the newest file there).

1. For the journal trades: n, average result per trade in R (x̄), standard deviation (s), win rate, biggest loss, max drawdown.
2. The range my true average is probably in: x̄ ± 1.96 × s ÷ √n. Is the backtest's average inside it?
   - Inside: the verdict is KEEP. The gap is noise so far. Tell me how many trades I need before the range is half as wide (4 × n).
   - Outside on the low side: the verdict is FIX. List the three most likely causes with the evidence for each: costs higher than assumed, slippage, rules not followed, or the market changed.
   - Max drawdown hit, or more trades broke the rules than followed them: the verdict is STOP.
3. Discipline: list every trade that broke a rule, every stop that was moved, every size that did not match the formula. Show my result with and without those trades.
4. Propose at most ONE change. It is only a proposal: it must go back through the rules, the test and the sizing before I use it.
5. Write reviews/[TODAY'S DATE].md with the verdict as the first line, then show me a one-screen summary.

Do not edit anything in rules/. Do not place trades.

More for this stepTrade journal coachClaude skillReview a year of your tradesClaude overnight jobTrading JournalGrok Bot

Or hand over the whole desk in one paste

This page also exists as one plain-text file. Paste the lines below into Claude Code or Grok Bot and it will ask for your numbers, then take you through its own steps.

Read https://hft.md/grok-claude/llms.txt and set up this trading desk with me. First ask for my market, how I trade, my account size and currency, my risk on one trade, my daily stop and my max drawdown. Then take me through the steps that belong to you, one at a time, and tell me exactly what to hand to the other AI.

Open llms.txt to see exactly what it will read.

How the two talk to each other

Everything above works by copy and paste. If you want the two to hand work to each other without you, these are the three ways, easiest first.

  1. You are the courier

    Start here

    Two things cross over. Your rules go from Claude Code to Grok Bot (step 5). Your journal comes back once a week (step 7). That is the whole link, and it takes a minute.

  2. One shared folder

    Needs a private GitHub repo

    Put the trading-desk folder in a private GitHub repo and connect GitHub in both apps. Claude Code saves rules and reports there, Grok Bot can read them there, and the journal goes back the same way. Less pasting by hand.

  3. They call each other

    Advanced

    A Grok Bot routine can start from a webhook: Claude Code finishes a test and sends one request, and the Bot messages you the verdict. A Claude Code cloud scheduled task can start from its own API trigger: the Bot finds an idea and starts the test. Both can also react to pull requests on the shared repo.

Show the two requests for the third way
# Claude Code -> Grok Bot: a routine's webhook trigger
curl -X POST "$BOT_WEBHOOK_URL" \
  -H "Authorization: Bearer $BOT_WEBHOOK_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event":"test_finished","verdict":"NO-GO","report":"tests/report.md"}'
# Grok Bot -> Claude Code: a cloud scheduled task's API trigger
curl -X POST "$CLAUDE_FIRE_URL" \
  -H "Authorization: Bearer $CLAUDE_TASK_TOKEN" \
  -H "anthropic-beta: experimental-cc-routine-2026-04-01" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"text":"New idea card from the scout: ..."}'
  • In Grok Bot, ask the Bot for a webhook trigger, then open the routine's Webhook section for the URL and key.
  • In Claude Code, add an API trigger to a scheduled task at claude.ai/code/routines and copy its Fire URL and token. The token starts that one task and nothing else.
  • The text you send arrives marked as untrusted data, so the task's saved prompt has to say what to do with it.
  • The Claude Code trigger is a research preview. Copy the current call from the task's own panel before you rely on this one.

Checked against both products' own docs on 6 December 2026. You do not need any of this for the seven steps.

The whole desk on nine cards

The same seven steps as images, free to save and share. Tap one to open it full size.

Before you connect anything

Both tools are paid. No Grok Bot? The prompts are plain text, so they work in any always-on agent:every free Grok Bot alternative. Want ready-made bots instead? Every trading Grok Bot. More for Claude: everything for Claude Fable 5.2.

Where the facts come from

Build a trading system with Claude.

Download ebook

hft.md shares free educational content. Nothing on this page is financial advice, and nothing here is a promise of profit. The worked examples use made-up numbers. Trading is risky: test on paper before using real money, and you are responsible for your own trades. AI agents make mistakes, so read what one proposes before you approve it. Grok Bot is an xAI product and Claude Code is an Anthropic product; hft.md is independent and not affiliated with either. Product facts were read from each company's own documentation on 6 December 2026.