How to Evaluate a New LLM on a Real Quant Backtesting Build
A practical method for judging a newly released large language model by asking it to build a historical backtest from personal trade records, using real files, external data, storage, and verification rather than simple demos.
Large language model evaluation is moving from “can it write a snippet of code” toward “can it finish a real, complex, and verifiable engineering task.” For developers, a model’s value depends less on reply speed or code length and more on whether it understands the business goal, breaks work into sensible steps, handles data correctly, and can locate and fix errors when they appear.
This article uses one example—building a historical backtest analysis system from personal trade records—to show how to evaluate a newly released model in a more objective way. The point is not to prove that one model is always better than another. It is to offer a reusable test: put the model in a real development environment, with real data, real interfaces, and real constraints, and then observe its overall behavior.
1. Design a complete task, not a demo
Many model demos focus on simple Q&A, code completion, or document summarization. Those cases show basic ability, but they do not fully reflect engineering skill.
A more useful test task should include at least the following:
- Input data is not a clean sample. It is a real file with format differences, missing fields, or inconsistent names.
- The task must call an external data interface, not rely only on the model’s memory.
- Results must be stored persistently, including table design and update strategy.
- The process must be observable, such as progress display, logs, and saved error messages.
- Outputs must be checked by a person. A program that runs is not enough.
A trading backtest system fits these requirements. It covers file parsing, data queries, time alignment, metric calculation, database design, and result interpretation, so it can examine a model more completely.
2. Step one: normalize the raw trade data
Files exported from trading software are usually tables. Common fields include trade date, security code, security name, buy or sell direction, fill price, fill quantity, fill amount, and fees.
Before handing the data to a model, define the data boundary and remove sensitive information. It is reasonable to keep:
- Trade date and time
- Instrument code
- Instrument name
- Buy or sell direction
- Fill price
- Fill quantity
- Costs such as commissions, taxes, and similar charges
- Order status or fill status
Account numbers, names, cash balances, and similar sensitive fields should be deleted or replaced. Passing a spreadsheet directly to the model is not always the safest choice. Complex sheets may contain merged cells, hidden columns, blank rows, formatted numbers, and multiple worksheets. A more reliable approach is to read the file in code first, clean the fields, and convert them into clearly structured text or data.
For example, standardize dates, drop empty values, convert numeric fields to numeric types, and normalize buy and sell direction. After that conversion, ask the model to check whether the fields are complete, rather than asking it to do all of the parsing.
3. Step two: use staged prompts so the task does not drift
On a complex project, telling the model once to “build a complete backtest system” is risky. It may generate a large amount of code while ignoring data definitions, edge cases, and verification.
A staged collaboration is more reliable.
Stage 1: Extract and check instruments
First ask the model to extract security codes and names from the trade records and output a deduplicated list. Confirm that list manually before moving on.
This step looks simple, but it can surface problems early:
- The same instrument appears in more than one code format
- Prefixes or suffixes are inconsistent
- Names have changed
- The file mixes in funds, convertible bonds, or other assets
- Records include canceled orders or invalid fills
Stage 2: Design the data acquisition plan
Before calling a data interface, ask the model to state which data it needs and what each type is for. Examples:
- Daily bars for trend, return, and volatility
- Intraday data for analyzing fill timing
- Adjustment information to avoid artificial price jumps
- A trading calendar for holding days and missing dates
- Corporate-action data for dividends, splits, and similar events
Do not rush into code. Review the data design first. Many backtest errors are not syntax errors. They are definition errors, such as using unadjusted prices for long-term returns, or treating non-trading days as holding days.
Stage 3: Implement download and local storage
While calling the data interface, require clear progress: current instrument, current date range, success count, failure count, and retry count.
A competent data-collection module should at least provide:
- Limited retries after request failure
- Rate-limit control
- Resume support for data already downloaded
- Deduplication of repeated records
- Logs of raw responses or error messages
- Checks on the data time range
- A count check after the download finishes
If the model only produces a simple loop and ignores retries, repeated runs, and data consistency, it has produced a draft, not an engineering implementation.
4. Step three: database design decides whether the system can grow
Saving everything as temporary files is quick to start, but later queries, incremental updates, and result reproduction become difficult. A local relational database with clear layers is a better fit.
Split the schema into four groups:
1. Raw trade table
Store the imported fill records with as little change to the original content as possible. Add an import batch id and a file-source identifier.
2. Market-data table
Store instrument code, trade date, open, high, low, close, volume, and turnover. Put a composite unique constraint on instrument code and trade date so the same bar is not written twice.
3. Instrument reference table
Store name, listing status, industry classification, and valid date range. For names or classifications that change, record the effective time instead of simply overwriting the old value.
4. Backtest result table
Store strategy name, parameters, run time, return, maximum drawdown, win rate, trade count, and risk metrics. Parameters must be stored with the results, or later experiments cannot be reproduced.
If a model’s database design only cares about “data can be inserted,” and ignores unique constraints, indexes, versions, and incremental updates, the project will become hard to maintain as the data grows.
5. Step four: look closely at code quality
Do not judge generated code only by whether it runs. Check these points as well:
Data types
Are dates, prices, quantities, and amounts using the right types? Are strings involved in calculations? Could floating-point error affect money results?
Time alignment
Does a buy use that day’s close, or the actual fill price? Do market data and trade data share the same time zone and trading days? Does the model accidentally use future data?
Trading costs
Are commissions, taxes, slippage, and minimum charges included? If costs are ignored, a high-frequency strategy can look much better than it is.
Price adjustment
Does a long holding analysis use a reasonable adjusted price? If a company pays a dividend or splits, can the model recognize the price change and avoid a false signal?
Exception handling
When the interface returns no data, or when a halt, limit move, missing value, or duplicate record appears, does the program report it clearly, or does it silently fill zeros?
These issues matter more than whether the code looks compact. A program can look complex and run successfully, yet still produce a report with no reference value if the data definitions are wrong.
6. Step five: build a backtest flow that can be checked
Separate data processing from interpretation of the conclusion. A minimum flow should include:
- Import and validate trade records
- Build the instrument list
- Download or read the matching history
- Match trade dates to market-data dates
- Calculate the actual result of each trade
- Aggregate by instrument and by the whole account
- Calculate risk metrics
- Produce an analysis report that can be traced
Common metrics include cumulative return, annualized return, win rate, profit-to-loss ratio, maximum drawdown, holding period, trade frequency, and return volatility.
Metrics still need the sample behind them. A high win rate does not mean a good strategy. If a few losing trades are much larger than many winning ones, the overall result can still be negative. The model should show the distribution of gains, the distribution of losses, and the change over time, not only a few attractive summary numbers.
7. How to handle stalls and unstable behavior
On a complex task, a long silence, repeated generation, or a stop in the middle does not always mean the model has no ability. Task size, context length, tool-call chains, and the runtime environment can all contribute.
A more stable way to work is:
- Split the large task into independent stages
- Save files and logs after each stage
- Ask the model to output a plan before writing code
- Limit the data range of a single operation
- Set timeouts for network requests and long calculations
- Keep scripts that can be run again
- Ask the model to report results and open issues at the end of each step
If the model is stable on stepwise tasks but loses control on one large request, its basic ability may be acceptable, while planning and long-running workflow management still need a person in the loop.
8. How to score a new model
For a test of this kind, score five dimensions:
- Understanding: Does it correctly grasp the business goal and data constraints?
- Planning: Can it break a complex task into reasonable steps?
- Coding: Is the generated code reliable, maintainable, and extensible?
- Debugging: When something fails, can it find the root cause instead of repeatedly editing surface code?
- Verification: Does it actively check results and notice lookahead, insufficient samples, and statistical bias?
A new model should not be judged only by how fast it answers or how much code it writes. What matters is whether it reduces repetitive work in a real project, helps the developer find hidden problems, and leaves results that can be reproduced and trusted.
For an individual developer, the best use is not to hand over the entire job. Let the model handle repetitive work such as data cleaning, script generation, documentation, and a first-pass analysis, while a person owns the requirement boundary, data definitions, risk judgment, and final acceptance. Only when model output and human review are combined does a simple trial become a maintainable, verifiable technical system.
