What can a coding assistant like Claude or Codex actually do for a trader, and why isn’t it a price-prediction model?
This post sets up a separate practice folder, gives the assistant a read-only first task, then has it write one small function, a simple moving average over five numbers, and checks it against numbers you worked out by hand. The easy mistake: treating “done” from the assistant, or two assistants agreeing with each other, as proof. Proof is a file, a command and a test result.
Terms used below:
- AI coding assistant: a tool that reads files, writes programs and finds errors, one small task at a time. Claude Code and Codex are examples.
- Prediction model: a model trained on market data to forecast prices. Nothing in this post uses one.
- Checkable output: a file, table or log you can open and check again.
- Diff: the lines a change adds or removes; what you read before accepting it.
- SMA (simple moving average): the mean of the last n closes at each candle.
Three roles: the assistant, a prediction model, and you
| Role | Does | Doesn’t |
|---|---|---|
| Coding assistant (Claude, Codex) | Reads documents, writes programs, checks errors; does one small task per prompt | Turn a vague description into an edge by itself |
| Prediction model | Is trained on data to forecast | Appear anywhere in this step |
| You | Write rules.md in your own words; read each diff and confirm each permission; compare results with a hand calculation |
Hand over the rules or the final check |
In this post Claude and Codex draft code; they don’t forecast the market. You keep the rules and check the results yourself.
Set up a separate practice folder
Make a new folder just for practice, open it in your tool, and add two small
files: rules.md, the rules in your own words, and data.csv, a few made-up
or exported closes with no account details. Use git so every change can be
undone, and don’t connect a broker yet. Never put a token or password in a
prompt or in a file you might share.
mkdir C:\trade-system-lab
cd C:\trade-system-lab
git init
mkdir data, src, tests, reports
notepad rules.md
notepad data\closes.csvdata\closes.csv for this post:
close
100.0
102.0
101.0
105.0
107.0Then ask for reading only: list the files, the units in the data and anything unclear. Only after you’ve read that answer does the assistant write anything.
The first output must be something you can read
A beginner who knows charts often starts with “make me a good bot”. Replace that with small, checkable asks:
- Read the folder; list the files, the data’s units and what’s unclear.
- Write a README with the demo’s purpose, how to run it, the data and the checks.
- Write one function, an SMA over 5 numbers, with a hand-worked result to compare.
- Read the diff and run the test before the next step. “Done” isn’t proof.
Work out the expected values by hand first and put them in rules.md:
| Candle | Close | SMA(3) by hand |
|---|---|---|
| 1 | 100 | not enough data |
| 2 | 102 | not enough data |
| 3 | 101 | (100 + 102 + 101) / 3 = 101.0 |
| 4 | 105 | (102 + 101 + 105) / 3 = 102.6667 |
| 5 | 107 | (101 + 105 + 107) / 3 = 104.3333 |
A version the assistant might write, src/sma.py:
def sma(values, n):
"""Simple moving average: the mean of the last n values at each position; None until n values exist."""
if n <= 0:
raise ValueError("n must be positive")
out = []
for i in range(len(values)):
if i + 1 < n:
out.append(None)
else:
window = values[i + 1 - n:i + 1]
out.append(round(sum(window) / n, 4))
return outAnd the test that ties it to your hand calculation, tests/test_sma.py:
from src.sma import sma
CLOSES = [100.0, 102.0, 101.0, 105.0, 107.0] # data/closes.csv, worked by hand in rules.md
def test_sma3_matches_the_hand_calculation():
# (100+102+101)/3 = 101.0, (102+101+105)/3 = 102.6667, (101+105+107)/3 = 104.3333
assert sma(CLOSES, 3) == [None, None, 101.0, 102.6667, 104.3333]
def test_sma5_is_the_mean_of_all_five():
assert sma(CLOSES, 5)[-1] == 103.0 # 515 / 5
def test_too_few_values_gives_none_not_a_guess():
assert sma(CLOSES[:2], 3) == [None, None]Run it (with src\__init__.py and tests\__init__.py present, and pytest
installed in the folder’s virtual environment as in the setup post):
.venv\Scripts\python -m pytest -q testsWhat you see: 3 passed. If a test fails, don’t ask the assistant to “fix the
test”: compare the numbers one by one with your table.
When can you move to the next step?
| Gate | Question | If not |
|---|---|---|
| 1 | Is there a file you can open and a command to run it? | Ask for the file name and the exact command |
| 2 | Did the test actually run, with a result? | “Done” isn’t proof yet |
| 3 | Does it match your hand calculation? | Stop, read the log, compare each number |
| 4 | Have you read the diff? | Don’t hand over the next task yet |
Only when all four pass do you give the next small task. Fail a gate, stop there, read the log and check one case by hand.
Worked example: split a BTC demo project into checkable tasks
The first idea: “AI finds BTC buys and pings me on Telegram.” That isn’t enough to program. First pick a baseline you can explain: judge only closed H1 candles, from a fixed price source, with the EMA condition written as numbers, a position size set by a budget, and no live trading. In this step the AI is a coding assistant, not a market-forecasting model.
| Step | Who | What |
|---|---|---|
| 1 | You | Write spec.md: source, timeframe, when the data is known, contract type, assumptions |
| 2 | Assistant | Return a plan of the files; propose only, edit nothing |
| 3 | You | Read and approve the plan |
| 4 | Assistant | Create one part at a time and explain how to check it |
| 5 | You | Run the command and compare with the expected output, on sample input; no orders |
If it doesn’t match, go back to step 4 and fix one small part at a time.
The folder:
trade-system-lab/
├── spec.md # source, timeframe, contract type, assumptions
├── data/ # sample data
├── src/ # script that reads the data and checks the signal
├── tests/ # tests against hand-worked results
└── reports/ # signal yes/no + timestampNo token goes in this folder. A project only runs when it has a terminal command, sample input and an expected output.
The deliverable: a script that reads the sample data and writes “signal” or “no signal” with a timestamp, and sends no order. If you can’t check this step by hand yet, adding Telegram or trading permissions only makes the errors harder to see.
Try it: the first read-only prompt
I'm new to this and have the folder trade-system-lab open, just for practice. Read only: don't edit files, don't install libraries, don't call any broker or API. List the files that exist, explain briefly what each does, then propose a plan to create rulebook.md, test-plan.md and one small Pine example. For each step, give the input, the result I should see and how to check it by hand. Mark anything I haven't provided; don't guess a strategy or parameters. Stop after the plan so I can read it. Don't ask for passwords, tokens or a real account.Never paste passwords, API keys or tokens into a prompt, and check whatever the AI returns on the demo account before relying on it.
The order to work in:
- Create
trade-system-lab; save the rules and prompts there, never a secret. - In Codex, open the right local folder; the first prompt asks for reading, a file list and a plan only.
- Paste
rulebook.mdinto Claude or Claude Code to find vague spots; only then give Codex one small task. - Read each diff and confirm each permission; don’t turn on a mode that skips all permission prompts.
Key takeaways
- The sample folder is
spec.md,data/,src/,tests/,reports/; the spec records the price source, timeframe and contract type, never a token or password. - The first prompt only lets the AI read, list files and name what’s unclear; then read each change and approve each permission.
- The deliverable prints “signal” or “no signal” with a timestamp and sends no order; if you can’t check it by hand, don’t add Telegram.
Comments