A starter template for developing and backtesting trading systems with Claude Code, the OPTD way: build the idea fast on TradingView, sniff it on a chart, then validate it honestly on Sierra Chart tick data.
This repo ships with a worked example — an Opening Range Breakout (ORB) indicator + strategy in Pine Script — and the one-shot prompt that builds them.
📺 The videos · 📧 Newsletter · 🌐 onepersontradedesk.com
Every video adds a runnable component to this repo. This table is the index, newest first. The method is always in the video, free.
⭐ Star the repo to follow along — a new row lands with every video, and stars are how other traders find this.
git clone https://github.com/drewautomates/optd-starter.git
cd optd-starter
python3 -m pip install -r requirements.txt # just numpy
python3 backtests/runs/run_gauntlet.pyThat runs all three bias tests end to end in a few seconds. Nothing to download, no API key, no broker account — every demo generates its own synthetic data, so it runs the same on Windows, macOS, and Linux, offline. Requires Python 3.9+.
Windows: use
pythoninstead ofpython3(orpy -3). macOS and most Linux distros ship onlypython3— that's the one difference in every command on this page. Run from the repo root; no virtualenv orPYTHONPATHsetup is needed, though a venv is never a bad idea.
Then, for the TradingView side:
- Paste
indicators/pine_reference/Opening_Range.pineandOpening_Range_Strategy.pineinto TradingView's Pine Editor, add to chart. - Use an intraday chart (1m–15m) on a futures symbol (
NQ1!,ES1!,MNQ1!). Chart TF ≤ Signal TF. - To rebuild the Pine from scratch with Claude Code, hand it
research/prompts/orb_indicator_and_strategy.md.
-
Indicator — see the setup on the chart (the eyes).
indicators/pine_reference/Opening_Range.pine -
Strategy + TradingView Strategy Tester — a quick "is there a pulse?" backtest. Fast, visual, imperfect.
indicators/pine_reference/Opening_Range_Strategy.pine -
Python pipeline — the honest verdict. The first layer is in: honest fills. A backtest can manufacture a fake edge out of nothing just by assuming fills it never got. Run it yourself:
python3 backtests/runs/run_fills_demo.py
It runs the same ORB through two fill models on random-walk data (which has no real edge). The honest fills report ~0, as they must. The naive fills conjure a positive expectancy from thin air — that gap is the lie. Files:
indicators/python/orb.py,backtests/fills.py,backtests/kernels.py. More gates (walk-forward, permutation, Monte-Carlo) fill in as I build the desk in public. -
Sierra Chart tick data — where honest fills come from. A backtest is only as honest as its data, and the honest-fills lesson turns on one bit per bar — did the high print before the low? — that lives in the ticks, not in OHLC. This slice is a teaching Sierra Chart
.scidreader: it writes a synthetic tick stream in the real.scidrecord shape, reads it back by parsing the bytes (the actual skill), and reconstructs bars from the ticks — then feeds those tick-rebuilt bars straight into the honest-vs-naive test. Run it:python3 backtests/runs/run_scid_demo.py
Same random-walk data (honest ≈ 0), but now the whole thing is anchored on the tick reading that makes honest fills possible in the first place. Once you can read the ticks, you reconstruct any strategy tick by tick instead of trusting a platform's guess. Files:
backtests/ticks.py,backtests/runs/run_scid_demo.py.
Step 2 is something anyone can do. Steps 3–4 are the differentiator: rigorous vibe coding for trading.
Every backtest tells you three lies. Each one has a test, all three are in this repo, and they run on synthetic random-walk data on purpose: random data has no edge in it, so every dollar these tests report as profit is provably fake. You watch each bias manufacture money and then hand it back — the lie, in a lab, where you can see all of it. Then you point them at your own results.
| Test | Command | What it catches |
|---|---|---|
| 1 · FIT | python3 backtests/runs/run_cheat_demo.py |
Let the backtest cheat — signal-close entries, no commission, fill on every touch — then take the cheats away one at a time. If it still loses at pass 0, you're done; nothing else needs checking. |
| 2 · FILL | python3 backtests/runs/run_fills_demo.py |
When your stop and your target land inside the same bar, which one hit first? The bar doesn't record it. Naive fills guess in your favour; honest fills don't. |
| 3 · FLUKE | python3 backtests/runs/run_drift_demo.py |
Take the signal away. Same times in, same times out, no signal — just be in the market. Run in a flat market and a rising one, because this test only bites in one of them. |
| all three | python3 backtests/runs/run_gauntlet.py |
End to end in a few seconds. |
Run them before you put money behind a strategy, not after.
Test three reports every gap against its own noise floor. The strategy and its control trade the same bars, so they're scored as a paired difference — the market's variance cancels and what's left is the part the signal is answerable for. A gap smaller than that floor comes back INCONCLUSIVE, not as a win. That one rule disqualifies more strategies than the three tests do, and it's the reason the flat-market run below refuses to call a +$0.83/trade result an edge.
Teaching layer vs production. What's in this repo is the teaching layer — the method, on synthetic data, so you can see the lie with zero hand-waving. The
.scidreader here parses the real record format but runs on a synthetic tick file. The production harness — the real.scidreader over live exchange files (timezone handling + a parquet cache that replays years in seconds so you can run thousands of permutations), the multi-gate validated kernel, and the production gauntlet running these same three tests over real exchange data — runs on the live desk and ships in the community. The three tests above are free and always will be. What's paid is the data and the engine, never the method. No methodology is ever gated.
optd-starter/
├── CLAUDE.md # project context for Claude Code
├── .claude/
│ ├── settings.json # tool permissions
│ └── agents/ # sub-agents (added as the desk grows)
├── data/
│ ├── tick/ # raw tick data (gitignored)
│ ├── cache/ # parquet cache (gitignored)
│ └── README.md # how to populate
├── research/
│ ├── prompts/ # prompt library (one-shot builders)
│ └── notebooks/
├── backtests/
│ ├── data.py # Bar + synthetic sessions (optional drift) + CSV loader
│ ├── costs.py # commission + slippage presets — the cheat ladder (test 1)
│ ├── fills.py # fill models — naive (the lie) vs honest (test 2)
│ ├── drift.py # the no-signal control + the noise floor (test 3)
│ ├── kernels.py # validated exit kernels + self-test
│ ├── ticks.py # teaching .scid reader (ticks → bars)
│ └── runs/ # runnable demos
│ ├── run_gauntlet.py # all three bias tests
│ ├── run_cheat_demo.py # 1 · FIT
│ ├── run_fills_demo.py # 2 · FILL
│ ├── run_drift_demo.py # 3 · FLUKE
│ └── run_scid_demo.py # ticks → bars → honest fills
├── indicators/
│ ├── python/ # Python implementations (parity with Pine)
│ └── pine_reference/ # Pine source — the spec
├── sierra/
│ ├── DEPLOY.md # deploy → build → verify, and the four gotchas
│ ├── scripts/ # deploy.ps1 / deploy.sh → your ACS_Source
│ ├── studies/ # .cpp ACSIL studies
│ ├── chartbooks/ # .Cht chartbooks
│ └── exports/ # Export Chart Data CSVs
├── journal/
│ └── schema.sql
└── README.md
This repo is the tangible companion to the One Person Trade Desk tour — the same roles, as folders. The judgment role (Portfolio Manager) is you; Claude Code is the bench that runs the rest.
| Folder | Desk role |
|---|---|
research/ |
Quant Researcher — ideas → specs, the prompt library |
indicators/ |
Quant Developer — Claude Code writes the code (Pine = spec, Python = parity) |
backtests/ |
Quant Researcher + Risk Manager — exit kernels, walk-forward, Monte-Carlo |
data/ |
Data Engineering — tick data + parquet cache |
sierra/ |
Execution Trader + Tech Infrastructure — ACSIL studies, live exports. Start at sierra/DEPLOY.md. |
journal/ |
Performance Analytics + Compliance — trade log + honest self-review |
Most of these are scaffolded today and fill in as I build each role on camera.
- Range from high/low, never closes — close-based collapses to a zero-width line when the OR window is a single signal-TF bar.
- Levels computed inline, not through
request.security— the OR high/low are timeframe-invariant, so computing them inline draws smoothly and makes the indicator and strategy match exactly. Pulling levels throughrequest.securitycauses a zero-width "snap"/immediate-drop and indicator-vs-strategy drift. - Only the consecutive-close counter is timeframe-dependent — it runs on a fixed Signal timeframe via
request.security, so swapping the chart view doesn't move the entries. - Return counts, not momentary booleans, across
request.security— momentarytrueflags don't survive the security boundary; detect the breakout edge on the chart side. - Futures need
margin_long/shortin thestrategy()call — the default (0) demands full notional (~$600k for 1 NQ), so a $50k account silently places zero trades ("This report requires trade data").
This repo fills in as I build the desk in public. The newsletter is where it connects — new drops, the methodology behind them, and the waitlist for the OPTD community when it opens.
In the works: the backtest bias-reviewer — a Claude Code skill that audits a backtest in seven layers, from lookahead in the data all the way to the biases that live in the researcher instead of the code. It drops with its own video when it's ready; the newsletter gets it first.
→ Subscribe · onepersontradedesk.com
MIT — see LICENSE. Educational/research only; not financial advice.