Trade-Record-Driven Backtesting in Practice
A practical engineering workflow for turning personal fills into repeatable backtests: standardize trade records, confirm tickers, ingest market data with a recoverable pipeline, and produce reports that state assumptions instead of relying on ad-hoc LLM table reading.
State the goal first
Many accounts swing for years with more losses than wins, yet it is still unclear whether the problem is timing, position size, or overtrading. A common piece of advice is to review your own fills until a repeatable pattern appears. In engineering terms that does not mean asking a model to “comment on a few trades.” It means a reviewable pipeline: standardize fills, confirm the ticker list by hand, load historical prices under explicit rules, replay under a single set of assumptions, and emit an analysis report that states those assumptions.
The value is turning subjective review into a repeatable experiment. The same fills, the same adjustment and fee assumptions, and the same price history should produce matching conclusions if you rerun later. If they do not, a fluent write-up is still narrative, not a basis for changing rules.
Why you should not dump the spreadsheet into a model
Broker or terminal exports are usually spreadsheets: date, symbol, name, side, price, quantity, notional, and fees in separate columns. Sending a binary workbook to a large language model often fails: only the first rows are read, numbers become strings, fee columns are dropped, or multiple fills in the same name are merged. The root cause is usually unstable parsing—merged cells, hidden columns, scientific notation, leading zeros stripped from symbols—not that the model “does not understand stocks.”
A more robust approach is to convert in deterministic code, then let the model summarize. The conversion is not about a fashionable format. It should satisfy four points:
- Each fill is one complete record with explicit field names.
- Symbols stay strings so leading zeros are not lost.
- Side, quantity, price, and fees use consistent units.
- The output text can be sampled by a person or a script, with the same row count as the source.
Lightweight marked-up text is a good model input because rows are clear and easy to chunk. Reconcile immediately: source row count, distinct tickers after dedup, and buy/sell notional totals must match the text side before you proceed. Ordinary scripts can do this; you do not need the model to “look like it understood.”
Sketch:
source sheet -> field mapping and type cleaning -> row-level checks -> marked text / structured table| |+---- on mismatch, stop; do not analyze ----+
Split a large task into checkable steps
Highly personal analysis goes off the rails when one prompt dumps the goal, sources, schema, metrics, and writing style. Models fill in assumptions: corporate-action adjustment, transaction costs, halted sessions, time alignment. One wrong choice invalidates the “objective” report.
A more reliable collaboration is: you write the process; the model or coding assistant does only the current step, each with an inspectable artifact.
- Extract names and symbols from fills; a person checks for delistings, renames, symbol changes, or typing errors.
- Pull prices only for the confirmed list; do not let the program expand the universe.
- Write prices to a local store; log ticker, range, rows written, and failure reasons.
- Align fills with prices and build backtest inputs; do not compute while still fetching.
- Report against metrics written in advance, and list data gaps that were not covered.
Step 1 must be human. Same name, different symbol, or one symbol mapping to different securities over time will stitch unrelated history if you auto-merge. Persist the confirmed list as a file; later steps read only that file so chat cannot casually change scope.
If a run produces no output for a long time, treat the job as unknown, not “still thinking.” Set timeouts, keep checkpoints of finished tickers, and resume from the breakpoint instead of wiping the batch. New or heavily loaded inference services are more likely to hang; progress logs and idempotent writes should catch that—not repeated manual pause clicks.
Market data: abstract the source, show progress, recover from failure
Personal backtests usually need daily bars and sometimes finer bars to check that a fill sits inside that day’s range. The vendor can change; the design should wrap “market data” as one interface: input symbol, start/end, frequency; output standard fields (session date, OHLC, volume, adjustment factor or already-adjusted prices). Swapping vendors then means only the adapter, not tables or replay logic.
Constraints worth keeping:
- Put credentials in local config or environment variables—not in prompts, not in the repo, not in chat logs.
- Loop by ticker; commit after each name and print progress such as “3/28, symbol, range, rows written.”
- Log empty series, permission errors, and rate limits separately; do not disguise failures as “no prices.”
- Repeat pulls for the same symbol and range should overwrite or skip so the job is reentrant.
- Intraday volume is large; partition by day and backfill only fill dates you need to check.
Progress is not decoration. The failure mode is thinking the pull finished while a few names sat on a rate limit. Logs should answer: who was requested, how many succeeded, the failure list, and where to resume.
Local schema that can grow with new metrics
The store need not start complex, but it should extend. Four table types in an ordinary relational database are enough.
- Master tickers: symbol, name, listing status, human-confirmed flag.
- Fill facts: one row per fill, keep source row numbers for audit; amounts, fees, and side as numbers and enums, not free text.
- Prices: unique on symbol, session date, frequency; record how prices are adjusted so daily bars and fill prices share a convention.
- Jobs and data quality: each pull’s window, row counts, errors; later reports cite a job id.
Later, industry maps, index comparison, or equity curves can be new tables joined on symbol and date without rewriting fills. Prefer views from queries; do not treat numbers the model wrote back as the only truth. The model can draft SQL or scripts, but results must be recheckable with aggregates—trade count, win rate, average holding days—spot-checked on a few names.
Write field conventions before code. Examples: whether buy cost includes fees, whether sell P&L deducts stamp tax and commissions, whether overnight marks use close or next open, whether halt days carry the prior close. There is no single right answer, but one report must not mix conventions.
What the report should answer
Replaying your fills is not the same as backtesting strategy signals. Inputs are trades that already happened, not model-generated entries. A useful report answers:
- If actual positions were held to a fixed exit (hold N days, or a given drawdown from cost), how P&L is distributed.
- Whether winners and losers differ stably in hold time, frequency, or size.
- Which names drove most drawdown—few large losses or many small ones.
- Whether fills often buy near the day’s high and sell near the low.
- Which names were dropped for missing data, and whether conclusions still hold after exclusion.
Keep metrics few and hard: trade count, win rate, payoff ratio, max drawdown, equity curve, monthly contribution. Avoid “sentiment scores” that cannot be computed from fills and prices. If you use a benchmark, say whether it is buy-and-hold in the same names or a broad index over the same window, and use the same adjustment convention as the fills.
Models are good at structured write-ups from validated summaries, flagging outliers, and listing fills that need human review. They are not good at inventing prices when history is missing, or treating a replay curve as a forecast of future returns.
Stability and a validation checklist
Early inference or coding assistants may hang. Encode the response in operating habits:
- Each prompt has only the current inputs, output path, and done criteria.
- Split long work into ticker batches with checkpoints.
- Scripts time out external calls, retry a bounded number of times with backoff.
- After load, assert: dates monotonic, prices positive, every fill symbol exists in master data.
- Before the report, print coverage; if coverage is low, state limits instead of forcing conclusions.
A simple done bar: all 28 master names confirmed; daily gaps empty or explained; 100% of fills join to prices no later than the fill date; fee totals match the source within rounding. If that bar is missed, analysis stops at the data layer.
How to use the output, and where it stops
The product is a structured mirror of your own history, not a trading order. The sample is one account over one period. Survivorship, regime change, and unbooked manual corrections distort patterns. Assumptions (fees, slippage, ability to trade the close) differ from live markets. Improved rules still need later fills that were not used for fitting; do not retune on the same tickets until the curve looks good.
If you store exports in object storage, prices in a database, and pull jobs in logs and monitors, choose access-controlled, auditable general-purpose services. Do not bind the process to one chat product. Models speed drafting and explanation; deterministic programs convert, fetch, load, and reconcile. With that split, personal fill replay becomes a process you can run again, not a one-off conversation.
