Evaluating LLM Coding Capabilities and Engineering Boundaries Through a Trading Review System
This article explores the practical engineering capabilities of Large Language Models (LLMs) by implementing a trading review system. It covers the distinction between historical trade review, scenario analysis, and strategy backtesting, and outlines a phased collaborative approach for development. Key topics include handling structured settlement data, market data collection, local database design for traceability and idempotency, exception recovery, and generating verifiable analytical reports. The article concludes with a security and evaluation framework to assess LLM-assisted development in real-world projects.
I. Evaluating LLM Coding Capabilities Through Real Engineering Tasks
The most direct way to evaluate whether an LLM is suitable for assisted development is not to ask it to write an isolated function, but to involve it in a small-scale project with real data, external dependencies, and business constraints.
A trading review system is a typical scenario: the input comes from settlement slips exported by securities trading software. The system needs to identify securities and transaction records, fetch corresponding historical market data, write the data to a local database, and finally generate analysis reports on returns, drawdowns, holding behavior, and trading habits.
This project seems simple, but it actually tests multiple capabilities simultaneously:
- Can it understand the business objective and distinguish between trade review and strategy backtesting?
- Can it accurately process tables instead of analyzing only partial records?
- Can it complete data collection based on API documentation, handling permissions, rate limits, and missing data?
- Can it design extensible data structures?
- Can it identify execution failures instead of describing unfinished tasks as completed?
- Can it ensure that every key conclusion in the report corresponds to data and calculation evidence?
Therefore, the more reasonable evaluation target is “the LLM’s ability to participate in engineering delivery,” rather than the chat performance of a specific version. Code generation is only one part; correct data, traceable processes, and verifiable results are the prerequisites for the system to be put into use.
II. Defining Goals: Trade Review vs. Strategy Backtesting
The original requirement is usually: “Put my trading records into historical market data and see where I went wrong.”
This statement contains at least three different types of tasks that must be separated before development.
1. Historical Trade Review
Historical trade review is based on executed transactions, reconstructing changes in cash, holdings, and account equity. It answers:
- Which securities or time periods do the main profits and losses come from?
- What proportion of returns is consumed by trading costs?
- Is the concentration of holdings too high?
- Are losses concentrated in a certain type of observable behavior?
If only settlement slips are available, without initial holdings, initial capital, capital transfers, and necessary corporate action records, it may not be possible to accurately restore the account return rate. In this case, the analysis scope should be limited rather than presenting seemingly complete account performance.
2. Hypothetical Scenario Analysis
Scenario analysis studies: What if a certain trade had exited early, reduced its position, or set different stop-loss conditions, how might the result have changed?
It helps understand the trading path but does not equate to validating a sustainable strategy. Because these assumptions may have been proposed after knowing the subsequent trend, there is naturally a look-ahead bias.
3. Rule-Based Strategy Backtesting
True strategy backtesting requires defining clear rules first, and then simulating trades step-by-step based on information available at that time.
For example, if a buy signal uses data that can only be calculated after the market close, it cannot be assumed that the trade was executed before the close on the same day. Otherwise, the system is actually using future information.
These three types of tasks should be implemented, named, and reported separately during development. A conclusion like “if I had sold earlier, I wouldn’t have lost” should not be packaged as a strategy conclusion with predictive power.
III. Processing Settlement Slips: Text for Understanding, Structured Data for Calculation
Trading software usually supports exporting tabular files. To help the LLM understand the fields, the table can be converted into clearly structured text, but the text conversion result should not be directly treated as a reliable ledger.
The conversion process may cause the loss of leading zeros in security codes, changes in date meaning, omission of negative signs, confusion of null values, and missing content across multiple worksheets. Amounts and quantities may also lose their original precision due to format conversion.
A more secure approach is to establish a dual-track input:
- The original file is fully preserved for traceability and auditing;
- The structured parsing result serves as the basis for calculation;
- The text preview is used to explain fields and for manual confirmation;
- Data validation results determine whether to allow entry into subsequent processes.
It is recommended to retain at least the following fields:
| Field | Purpose | Validation Focus |
|---|---|---|
| Trade Date and Time | Reconstruct trade sequence | Check for missing timezone or time components |
| Security Code | Associate target and market data | Save as text to avoid losing leading zeros |
| Buy/Sell Direction | Calculate position changes | Unify mapping, identify non-trading activities |
| Executed Quantity | Update holdings | Check units and sign conventions |
| Execution Price | Calculate transaction amount | Distinguish original price from display format |
| Fee Details | Calculate net returns | Avoid duplicate deductions |
| Transaction ID | Deduplication and traceability | Check if the source is unique |
After parsing, record counts, date ranges, the number of securities, and the summary of buy and sell amounts should be cross-checked. Sampling against the original file should also be performed to confirm correct field mapping.
Special attention: The execution price multiplied by the executed quantity usually yields the transaction amount, which does not necessarily equal the actual cash flow change. Fees, capital transfers, and other business records need to be handled separately.
IV. Adopting Phased Collaboration Instead of One-Shot Generation
Handing all requirements to an LLM at once tends to produce a result of “lots of code, little validation.” The system might have a complete directory structure and a beautiful report, yet lack accurate data definitions.
A more effective method is to break the development process into stages with acceptance criteria.
Phase 1: Identify Inputs and Business Scope
First, let the model sort out settlement slip fields, security lists, trading date ranges, and abnormal records, without rushing to generate collection programs.
Acceptance criteria: All input files are identified, security codes are cross-checked, unexplainable records are explicitly listed, and silent discarding is not allowed.
Phase 2: Validate Data Sources
Based on the official documentation of data services, confirm the availability of daily lines, minute lines, trading calendars, and corporate action data.
Test a small number of securities over a short time interval first, recording permissions, return structures, date coverage, and failure reasons, before deciding on the batch fetching scope.
Phase 3: Implement Collection and Storage
The focus of this stage is not “being able to send a request,” but supporting breakpoint resumption, repeated execution, error recovery, and data validation.
Phase 4: Implement Ledger and Metrics
First validate cash and holding changes, then calculate return and risk metrics. If the underlying ledger is unreliable, the richer the subsequent charts, the greater the risk of misleading.
Phase 5: Generate Verifiable Reports
The final report must specify the data scope, calculation definitions, missing conditions, and conclusion limitations. The model is responsible for organizing the language, but the numerical values must come from explicit calculation programs.
Each stage should produce independent deliverables, allowing the next stage to proceed based on accepted results.
V. Market Data Collection: Validate Interfaces Before Pursuing Coverage
After obtaining the security list, the system should not immediately download all historical daily and minute-level data.
First, determine the granularity based on research objectives. Daily lines are typically suitable for holding periods, phased fluctuations, and account equity analysis; minute lines are suitable for more granular execution timing studies, but the data scale is larger, and permissions and historical coverage may be more restricted.
If the research is on holding returns over several weeks, daily lines may suffice. If researching short-term price changes after a transaction, finer-grained data is required, and its available scope must be clarified.
1. Establish a Data Capability Inventory
For each data type, record the following:
- Required permissions;
- Queryable historical intervals;
- Data update frequency;
- Request limits;
- Field definitions;
- Price and adjustment basis (e.g., adjusted vs. unadjusted);
- Handling of missing and anomalous data.
A successful API request does not mean complete data. An empty return might mean a non-trading day, a trading halt, insufficient permissions, or incorrect parameters. The system must classify and determine these states.
2. Maintain Consistent Price Definitions
Historical execution prices and adjusted prices used for trend display cannot be directly mixed in calculations.
Adjusted series are suitable for observing continuous trends, but the reconstruction of actual cash and holdings should be based on actual transactions, dividends, stock splits, and other related events. Using adjusted prices directly to calculate historical transaction costs may produce fictitious returns.
Multiple data sources should not be simply concatenated. Different sources may differ in time labels, volume units, trading session ranges, and adjustment methods. When switching data sources, source identifiers should be retained and consistency checks performed.
3. Perform Business Validation for Completeness
In addition to checking for duplicate records, time sequence, and price relationships, the expected coverage range should be evaluated using the trading calendar.
Missing market data for a specific day should not be automatically filled with the previous day’s price to continue trading simulation. Trading halts, missing data, and no trades are different states and have different impacts on backtest results.
VI. Local Database Design: Traceability, Incremental, and Idempotent Writes
For personal review projects, a local relational database can usually meet initial needs, but the table structure should avoid cramming everything into a single table.
It is recommended to split tables by responsibility:
- Security basic information: code, name, market, and valid time;
- Original transaction records: source file, original row position, transaction fields;
- Standardized transaction records: cleaned business fields and mapping relationships;
- Market data: security, time, period, price definition, and source;
- Cash and position snapshots: ledger status at corresponding points in time;
- Collection tasks: request scope, status, retries, and error messages;
- Analysis results: metric versions, parameters, and input data versions.
The unique key for market data cannot rely solely on security code and date; it must also consider data period, price definition, and source to avoid overwriting different datasets.
Executing the same collection task repeatedly should produce the same valid result, rather than adding duplicate rows. This is the basic requirement of idempotency. Unique constraints, transactional writes, and explicit update strategies can be used for implementation.
Original data and cleaned data should be stored separately. This way, when field interpretations or calculation definitions change, they can be reprocessed without having to re-fetch all data.
VII. Progress Visibility and Exception Recovery
A lack of output for an extended period during AI-assisted programming should not be directly attributed to a model failure. The cause may be waiting for external requests, runtime environment blocking, tool call timeouts, or output display delays.
The system should convert this uncertain state into an observable state.
At a minimum, it should display:
- Current phase and current security;
- Number of completed, failed, and pending tasks;
- Time of the last successful write;
- Current request duration;
- Number of retries and reasons;
- Next step.
Requests should have reasonable timeouts and distinguish between permission failures, rate limits, network errors, and field validation failures. Permission issues usually require configuration changes; blind retries are meaningless. Temporary network faults can use a limited number of interval retries.
Successfully fetched data should be written to disk promptly. After a task interruption, only the uncompleted parts should be processed, rather than downloading from scratch.
External validation should also be performed on the LLM’s “completed” descriptions: check database records, run tests, and compare expected date coverage, rather than solely trusting the summary in the conversation.
VIII. Backtesting Metrics Must Be Built on a Correct Ledger
Account equity usually consists of cash and the market value of holdings, but actual reconstruction must also consider fees, dividends, capital transfers, and trading rules.
External capital transfers cannot be treated as investment returns. If the account frequently adds or withdraws funds during the research period, a return measurement method that can handle cash flows should be chosen, and the method used should be noted.
A basic report can include:
- Realized and unrealized profits and losses;
- Total fees and their proportion;
- Position concentration;
- Maximum drawdown;
- Profit distribution per trade;
- Holding period distribution;
- Turnover rate;
- Performance relative to a defined benchmark.
Maximum drawdown describes the largest decline in equity from a historical peak to a subsequent trough, and should not be confused with the maximum loss on a single trade.
Win rate alone cannot represent trading quality. A high win rate may be accompanied by a few massive losses, while a low win rate may still yield positive returns due to larger profit magnitudes. Therefore, it is necessary to simultaneously observe profit and loss magnitudes, costs, and drawdowns.
For accounts with few trades and a short research period, statistical results should be interpreted cautiously to avoid identifying random fluctuations as stable patterns.
IX. Letting Models Explain Facts Rather Than Make Definitive Judgments
The analysis report should distinguish three layers of content.
The first layer is facts, such as net returns over a certain period, total fees, or position ratios.
The second layer is statistical observations, such as a return difference existing between the frequent trading group and the low-frequency trading group. Such comparisons must explain the grouping method and sample size.
The third layer is hypotheses to be verified, such as whether a certain trading behavior might be related to losses. This cannot be directly elevated to a causal conclusion, nor can it be deduced as an inevitable future loss.
Emotional evaluations like “the account is heading toward destruction” have no technical value. A more professional expression should explain: what risk was observed in which sample interval, what the evidence is, which explanations remain uncertain, and what data is needed to verify it.
To reduce unfounded generation, the model can be required to only use results already calculated by the program, and each core conclusion should correspond to a metric, sample range, or detailed record. When there is insufficient evidence, it should explicitly state “current data is insufficient to judge.”
X. Security and Evaluation Framework: From Runnable to Deliverable
Settlement slips and data credentials are sensitive information. During development, access credentials should be separated from business documents, using controlled configurations or secret storage. Credentials should not be written into prompts, source code, logs, or analysis reports.
Data sent to the model should follow the principle of minimum necessity, removing irrelevant identity information such as names and account numbers. Original files, databases, and reports should also have appropriate access controls and backup mechanisms.
Finally, the performance of LLM-assisted development can be evaluated across the following dimensions:
| Dimension | Core Checkpoint |
|---|---|
| Requirement Understanding | Distinguish clearly between review, scenario analysis, and strategy backtesting |
| Data Processing | Verify completeness and retain abnormal records |
| Documentation Usage | Validate permissions, fields, and coverage ranges first |
| Engineering Implementation | Support idempotency, incremental updates, timeouts, and recovery |
| Calculation Credibility | Handle fees, cash flows, and price definitions |
| Report Quality | Traceable conclusions with stated limitations |
| Security | Avoid leaking credentials and personal information |
What this type of project truly tests is not how much code the model generated at once, but whether it can continuously produce verifiable results under explicit constraints.
For developers, the most effective collaboration model is: humans take responsibility for business definition, data authorization, and confirming key definitions; the model assists with requirement decomposition, program implementation, test writing, and report organization; the program handles deterministic calculations; and the acceptance mechanism determines whether the task is truly complete.
When inputs are traceable, execution is observable, calculations are verifiable, and conclusions have boundaries, the LLM can evolve from a “code generation assistant” into a reliable part of the engineering process.
