Build Your Own Automated Options Trading System · Bonus

Backtesting by conversation.
Plugging an engine into Claude.

A backtest engine is a machine that answers questions about the past. A connector lets Claude operate that machine directly — you describe the strategy in English, Claude writes it, submits it, and reads the results back. Twenty backtests in an afternoon instead of a week.

Bonus lesson
connectors · MCP · backtest engine
Fast research. Slow deployment.
This lesson, in one glance

Same five beats. New idea.

1
Idea
A connector gives Claude hands. It stops advising you about backtests and starts running them.
2
Outcome
You describe a strategy in plain English. A finished, validated backtest comes back with metrics.
3
Vocabulary
connector · tool call · strategy class · run id · poll
4
Hands-on
Connect it, ask one question, read one metrics block. Fifteen minutes.
5
War story
A 20-run window sweep that found a winner — and two traps that would have cost real money.
1 · The idea

Claude with a connector isn't a smarter advisor.
It's a pair of hands.

Claude without the connector

  • It writes you code. You copy it into an editor.
  • You wire the data. Find a source, fix the timestamps, handle the expiries.
  • You run it. It crashes. You paste the traceback back into the chat.
  • You read the output. You summarise it back to Claude by hand.
  • One idea per evening. The loop is you.

Claude with the connector

  • It writes the strategy class in the engine's own format.
  • It validates the code against the engine before spending a run.
  • It submits the backtest and holds the run id.
  • It polls until finished, then pulls the metrics itself.
  • Twenty ideas per afternoon. The loop is the machine.
The difference isn't intelligence. It's the number of round trips through a human.
1 · The idea, mechanically

A connector is a menu of verbs the service hands to Claude.

The vendor publishes a list of actions — run this, fetch that, check status. Claude reads the menu, picks the right verb, fills in the arguments, and reads the reply. You never see the plumbing. The open standard for this menu is called MCP, the Model Context Protocol.

What it gains

  • Real execution — results come from the engine, not from a guess.
  • The engine's own data. No downloading, no cleaning.
  • Structured replies Claude can compare run against run.

What it does not gain

  • No access to your broker. No orders, ever.
  • No access to your machine's files.
  • Nothing beyond the verbs on the menu.

What it costs

  • Your plan's run quota — a sweep of 20 spends 20.
  • Context, if you pull raw trade lists instead of summaries.
  • A new way to be confidently wrong, fast.
2 · The outcome — the menu itself

Roughly thirty verbs, in four families.

Write & submit

validate_code — syntax check, free run_backtest — submit, get run id strategy_status — is it done? active_backtests — what's queued stop_backtest — kill a bad run

Read results

metrics — the summary block drawdown — worst stretches daywise_pnl — per session tradewise_pnl — per trade trades — the raw fill list

Compare

compare_backtests — run vs run combine_reports — portfolio view run_details — the parameters used analysis — deeper cuts

Data & docs

available_duration — how far back data / day_data — raw candles list_skills — the manual get_skill — read one page user_plan_info — quota left

The one you'll use ninety percent of the time is metrics.

It returns net P&L, Sharpe, Calmar, max drawdown, win rate and trade count in a block small enough to compare twenty of them side by side. Do not ask for trades or the intraday P&L curve unless you actually need a single trade explained — a raw trade list can be megabytes, and it crowds out everything else in the conversation.

2 · The outcome — the loop

Six steps. You perform one of them.

  YOU   "Short the ATM straddle on NIFTY expiry day at 09:20,
        50% stop on each leg, exit 15:10. Last two years."
         |
  1    --> Claude reads the engine's own strategy guide          get_skill()
         |
  2    --> Writes a strategy class in the engine's format       add_managed_leg(), stops, exits
         |
  3    --> Checks it compiles BEFORE spending a run             validate_code()
         |                                                       costs nothing
  4    --> Submits it, receives a run id                        run_backtest()
         |
  5    --> Waits, checking every few seconds                    strategy_status()
         |
  6    --> Pulls the summary and explains it                    metrics()
         |
  YOU   "Now do the same thing at 09:45. And 10:15."
        ...and this is where an afternoon becomes twenty backtests.
2 · The outcome — what it looks like

The whole exchange, start to finish.

claude — backtest connector
> Backtest a NIFTY opening-range breakout. Build the range from
  09:15 to 11:15, then short the breakout side's option from 11:16.
  50% stop loss, square off 15:10. Two years, one lot.

  Reading the strategy guide...
  Writing the strategy class...
  Validating...                                    PASS
  Submitting backtest...                           run 27fe49b9
  Running .......                                  COMPLETE

  Net P&L        Rs 55,707
  Calmar         1.74
  Sharpe         2.47
  Max drawdown   Rs 32,010
  Trades         348

> Now the same thing but start the range at 09:45.

  Submitting...                                    run 80e65b63
  Running ....                                     COMPLETE

  Net P&L        Rs 134,054      (+141%)
  Calmar         4.68
  Sharpe         5.94

> ...that's a big jump for half an hour. Run the three windows
  in between before I believe it.

  <-- this is the sentence that saves you money.
3 · Vocabulary

Five words to carry out of this lesson.

connector
A service that hands Claude a menu of actions it may perform. Also called an MCP server.
"connect the backtester"
tool call
One use of one verb from that menu. You see it as a line of progress; it's a real request.
run_backtest(...)
strategy class
The engine's own code format for describing entries, legs, stops and exits. Claude writes it, not you.
add_managed_leg()
run id
The receipt for a submitted backtest. Keep it — it's how you re-open a result months later.
80e65b63-c969-...
poll
Asking "done yet?" on a loop. Backtests are slow; the connector waits so you don't have to.
strategy_status(id)
You will never type any of these. You need the words so you can tell when a result is real.
4 · Hands-on

Fifteen minutes, from nothing to your first result.

Do this exactly

  1. Connect it. In Claude's settings, add the backtest service as a connector and authorise it. One-time.
  2. Ask what it can see. "How far back does your NIFTY data go?" — you should get a start date and a day count. If this fails, nothing else will work.
  3. Ask for the manual first. "Read your strategy-writing guide before you write anything." Skipping this is the single most common cause of a wasted run.
  4. Describe one strategy in plain English. Entry time, legs, stop, exit time, date range, quantity. Five sentences is plenty.
  5. Insist on validation. "Validate the code before submitting." Validation is free. A failed run is not.
  6. Ask only for the summary. "Give me metrics only — don't pull the trade list."
  7. Then change exactly one thing and run it again. One variable at a time, or you learn nothing.
If the first answer looks fantastic, that is not success. That is the moment to get suspicious — see the next three slides.
5 · War story — the sweep

Twenty runs in one afternoon. Here are five of them.

One question — does it matter what time the opening range starts? — asked five ways, on two indices, over two date ranges. By hand this is a week of work, so nobody does it, so nobody finds out. Same strategy, same stops, same costs. The only thing that changes is the clock.

Range start time vs. result — identical strategy, 1 lot, costs included
Range startsNIFTY netNIFTY CalmarSENSEX netSENSEX Calmar
09:15Rs 55,7071.74Rs 94,0403.30
09:45Rs 134,0544.68Rs 93,7852.98
10:15Rs 79,7502.84Rs 46,1320.91
10:45Rs 63,6842.53Rs 17,4720.44
11:15Rs 83,2042.79Rs 41,9800.93
Half an hour of clock — nothing else — is the difference between Rs 55,707 and Rs 134,054.
5 · War story — trap one

The first sweep only tested three times. It told a story that wasn't true.

What three points said

  • Tested 09:15, 10:15, 11:15 only.
  • NIFTY looked like it got better later in the morning.
  • SENSEX looked like it got worse.
  • Conclusion: the two indices need different settings.
  • That conclusion would have shipped two strategies, two configs, twice the things to break.

What five points said

  • Added 09:45 and 10:45 — the gaps.
  • Both indices peak in the same 09:15–09:45 region.
  • The "divergence" was the grid skipping NIFTY's best point and landing on SENSEX's.
  • Conclusion: one setting fits both.
  • Cost of finding out: two extra runs, four minutes.
A sparse grid doesn't return "no answer". It returns a confident wrong answer, in the same font as a right one.
5 · War story — trap two

The winner won because it was measured. Then it has to be discounted.

09:45 is the best of five. But it was chosen as the best of five — and picking the maximum of anything flatters it. The honest question is not "what did the winner make?" but "what does its neighbourhood make?"

Rs 134k
what the winning window made
the number you want to plan on
~Rs 90k
average of the winner and its two neighbours
the number you should plan on
4 of 8
years the "winner" ranked 4th or 5th of five
it was ordinary before it was dominant

Why the neighbourhood, and not the peak?

Because next year's market will not politely reproduce this year's best half-hour. If a setting only works at exactly 09:45 and falls apart at 09:15 and 10:15, you haven't found an edge — you've found a coincidence with good manners. A real edge is a broad hill, not a single spike. Budget for the hill.

5 · War story — the rules that came out of it

Three rules. Each one was paid for.

A backtest is research, not a config file

  • Numbers that come out of a backtest never get copied into a live system as-is.
  • The backtest proves the idea is worth building. The live settings are decided separately, on purpose, by a human.
  • A backtest models a market with no queue, no rejection, no outage.

Know what the engine's "close" actually is

  • Many engines call the last traded price of the day the close.
  • The exchange's official close is a weighted average of the final minutes. They are different numbers.
  • On roughly one day in a hundred they disagree about whether the day was up or down.
  • If your rule depends on up-vs-down, that 1% is your rule quietly failing.

Pull summaries, not raw data

  • Ask for metrics. Twenty of them fit in one conversation.
  • Ask for trades only to explain one specific trade you already care about.
  • A conversation clogged with raw fills is a conversation that has stopped thinking.
The connector made the research twenty times faster. It did not make it twenty times more trustworthy.
Bonus lesson — takeaway

The bottleneck was never computing power.
It was round trips through you.

Connect the engine and a week of backtesting becomes an afternoon. Which means the discipline — sweep the gaps, discount the winner, plan on the neighbourhood — is now the only thing standing between you and twenty confident wrong answers.

End of Backtesting by Conversation

Next: from backtest to one lot.

figures: 20-run opening-range window sweep, Aug 2026 · 1 lot, costs and slippage included · pre-tax
← → navigate · F fullscreen · click to advance
1 / 15