A Practical Guide to LLM Agents for Quantitative Analysis and Research Report Generation
This guide explains how LLM agents can turn financial analysis requests into executable, checkable workflows. It covers task checkpoints, factor interpretation, failure recovery, consistent calculation rules, data-driven charts, a single result source, the boundary between news retrieval and research conclusions, evaluation criteria, and practical security and rollout advice.
1. From Model Q&A to a Verifiable Analysis Workflow
When large language models are used for financial analysis, the most important change is not longer or more professional wording. It is whether a natural-language task can be turned into a workflow that can be executed and checked.
In a traditional question-and-answer pattern, the model reads tables, explains metrics, and writes conclusions directly. For a small amount of data, this can help with understanding. With multiple worksheets, long time series, and complex factor logic, however, answers generated only from context are prone to omissions, misalignment, and confusion about calculation definitions.
An agent pattern combines the model with an execution environment. The model interprets the request, breaks down the task, and organizes tool calls. The execution environment reads files, runs calculations, creates charts, and produces documents. A relatively complete research-report workflow can be represented as:
Requirement definition → data checks → factor-logic analysis → metric calculation → chart generation → evidence organization → report assembly → validation and delivery
The value of this pattern is that it shifts the process from “what the model believes the result is” to “what the program calculated under explicit rules.” Program execution does not automatically guarantee correctness. If the model selects the wrong column, misunderstands a unit, or writes an incorrect algorithm, the calculation can still produce a wrong answer consistently.
Agent capability should therefore be judged by both task completion and result verifiability, not only by whether the final report looks polished.
2. Which Capabilities Actually Affect Results
2.1 Whether task planning includes checkpoints
Breaking a task into a checklist is the foundation of a long workflow, but the checklist must include explicit inputs, outputs, and acceptance criteria.
For an inventory-and-basis analysis, it is not enough to write “read the data, calculate the metrics, and generate the report.” The plan should further specify:
- Which worksheets, date fields, and numeric fields to read
- The statistical scope and unit of measurement for inventory data
- Which price relationship and direction define the basis
- Which trading day the current value corresponds to
- Which sample window is used for historical percentiles
- How charts and the narrative share the same calculated results
- Whether execution may continue when data is missing
If these conditions are not fixed in advance, the agent may add assumptions while completing the task. The report may look complete without answering the question the user actually cares about.
2.2 Whether existing factor logic can be explained
Analyzing quantitative code is not only about summarizing what a function does. It also requires reconstructing the factor’s business definition and data dependencies.
In particular, check the following:
- The order of the time series
- Whether a rolling window includes the current observation
- Whether signal calculation uses data that was not yet available at the time
- Whether prices and inventory are aligned to the same date
- Whether units from different sources are consistent
- Whether missing values were filled, and whether filling changes the meaning of the signal
Reading a piece of source code does not mean the full context has been understood. A factor may depend on configuration in other files, preprocessing results, or a trading calendar. A reliable agent should clearly list what has been confirmed and what still requires human confirmation, rather than presenting uncertain points as established facts.
2.3 Whether failures can be recovered from reasonably
Unreadable files, unparseable dates, missing fonts, failed web retrieval, and document pagination errors are common. The user experience of an agent depends largely on whether it can locate the error, not on simply repeating the run.
A reasonable recovery mechanism should:
- Keep logs from the failed stage
- Distinguish data problems, code problems, and environment problems
- Re-run the affected steps after a fix
- Avoid reusing incomplete results produced before the failure
- Stop clearly once the retry limit is reached, and state what is missing
The goal of automation is not to hide errors, but to make them easier to find and handle.
3. Precise Calculation Depends on a Consistent Definition
3.1 Percentile differences do not necessarily come from arithmetic mistakes
When different analysis workflows report different percentiles for the same metric, the first check should be whether the definitions match.
“Where the current value ranks in history” usually means the percentile rank of the current value within a historical sample. “The value that corresponds to a given percentile” is a different question. The two are related, but they should not be conflated.
For the historical rank of current inventory, common definitions include:
- The share of observations strictly below the current value
- The share of observations less than or equal to the current value
- A mid-rank treatment for observations equal to the current value
Results can also differ substantially depending on whether the sample is the full history, the most recent several years, the same season, or the period after a regime change. Whether the current observation is included in the historical sample also needs to be stated.
A report should therefore not provide only a percentage. It should also record the sample start and end dates, the effective sample size, the current value, the missing-value treatment, and the tie rule.
3.2 Write the formula as an executable rule
The neutral pseudocode below shows one method that uses mid-ranks for ties:
function historical_rank(historical_sample, current_value):if current_value is not a finite number:return error("invalid current value")valid_sample = finite values in historical_samplesample_size = number of values in valid_sampleif sample_size equals zero:return error("no valid historical sample")lower_count = number of valid values less than current_valueequal_count = number of valid values equal to current_valuerank_ratio = (lower_count + 0.5 * equal_count) / sample_sizereturn rank_ratio * 100
This is only one optional definition, not a universal standard for every use case. In practice, choose a rule according to the research purpose and keep it consistent across runs.
For observations that are theoretically equal but differ slightly because of numeric representation, precision or tolerance rules should also be defined in advance. Setting a tolerance arbitrarily can change the statistical result.
3.3 Separate displayed decimals from calculation precision
It is not accurate to say simply that “a large language model cannot handle precise decimals.” The more precise statement is that asking a model to generate complex numeric results directly lacks a verifiable calculation guarantee. A validated execution program can substantially improve reproducibility, but data types, rounding rules, and the algorithm implementation still need attention.
For example, a percentile can retain full internal precision and be shown to one decimal place only in the report. Amounts, prices, and other precision-sensitive data should use the numeric representation and rounding method required by the business rule.
The narrative, chart labels, and appendix tables should all read the same result. The model should not restate or re-estimate those numbers separately.
4. Charts Should Come from Data, Not Visual Guesswork
4.1 Distinguish data plots from illustrative images
Trend lines, bar charts, and scatter plots in financial research reports need to express explicit data relationships. Charts produced by a plotting program can tie each point, axis, and label to a specific value, and they can retain the plotting inputs and script.
Visually generated images can illustrate a concept, but they should not carry time series, price levels, or statistical proportions that readers need to read precisely. An image can look like a professional chart without its coordinates corresponding one-to-one with the data.
Figures that support quantitative conclusions should therefore be produced in a data-driven way.
4.2 Data-driven does not mean a chart is automatically correct
A chart can still mislead readers because of incorrect date order, mixed units, or an unreasonable axis range. Necessary checks include:
- Whether horizontal-axis dates match the original records
- Whether vertical-axis units are clear
- Whether missing intervals are connected inappropriately
- Whether dual-axis charts are clearly labeled
- Whether the current-value marker corresponds to the correct date
- Whether the legend, title, and data-source note are complete
If the report discusses “current inventory being low relative to history,” the chart should preferably show both the historical distribution and the position of the current value, not only an inventory curve. Graphic design should serve conclusion checking, not decoration.
5. Use a Single Result Source to Avoid Internal Conflicts
A complete automated research-report system should save calculated results as a separate structured file. At a minimum, it should include:
| Field | Purpose |
|---|---|
| Analysis cutoff date | Fix the data timestamp of the report |
| Metric name and unit | Prevent mixed definitions |
| Current observation | Support chart labels and narrative citations |
| Sample window and size | Explain the scope of the statistic |
| Calculation rule | Support reproduction and audit |
| Result value | Serve as the report’s single data source |
| Data and script versions | Support change tracking |
Narrative generation, charting, and appendix layout should all consume this result, so that each stage does not calculate independently.
After the document is exported, also check font rendering, chart clarity, pagination, truncated tables, and whether citations match their sources. Successfully producing a portable document does not mean the research report is ready to deliver.
Sentences that contain numbers should be checked automatically against the structured result. Numbers that have not been calculated or supported by evidence should not enter the final text.
6. Keep a Boundary Between News Retrieval and Research Conclusions
An agent can help retrieve market information, but a news summary cannot directly replace causal analysis.
If inventory declines and prices rise at the same time, their coincidence in time is not enough to claim that the former caused the latter. Supply and demand changes, transportation conditions, trading structure, and other evidence also need to be considered.
A report should distinguish three kinds of content:
- Data facts: obtained from tables and program calculations
- Source statements: information described by external material
- Analytical inferences: interpretations formed from facts and sources
External material should record its publication time and scope of applicability. When it is used for historical backtesting, confirm that the material was already public at the corresponding decision time, so that look-ahead bias is not introduced.
If reliable information cannot be retrieved, state that the evidence is insufficient instead of filling the gap with a narrative that merely fits common sense.
7. How to Evaluate the Actual Experience of Using an Agent
Comparing writing style is less useful than designing a common task and repeating it on the same data, sample window, and calculation rules.
Focus on these dimensions:
- Numeric accuracy: whether results match a manually confirmed benchmark
- Workflow completeness: whether data checks, calculation, charting, and export are all completed
- Traceability: whether the data and rules behind each conclusion can be found
- Repeatability: whether repeated runs stay consistent
- Exception handling: whether empty data, wrong units, and missing files are recognized
- Interaction burden: how much information the user must supply and how many corrections are needed
- Resource cost: whether total time, number of runs, and human review cost are acceptable
The experience should not be judged only by whether “one sentence completes all the work.” For high-risk tasks, an agent that asks about key definitions is often more valuable than one that delivers without confirmation.
8. Security and Implementation Advice
When handling financial data, execution privileges should follow least privilege. The readable directory, output directory, network access, and script-execution scope need explicit limits. For sensitive data, log content and file retention periods should also be controlled.
Operational instructions that appear in input files or retrieved material should be treated as content to analyze, not as authorized commands. An agent must not send local files to an external location merely because a document asks for data to be uploaded.
A practical rollout can proceed in three steps:
First, fix a narrow task, such as historical-percentile analysis for a single metric, and build a human benchmark plus abnormal test samples.
Second, separate calculated results, charts, and the report template, and connect them through one result file to reduce repeated calculation and numeric conflicts.
Third, add news retrieval, multi-metric analysis, and scheduled execution, while gradually improving access control, run logs, quality checks, and human approval.
The core value of an LLM agent is to reduce the cost of organizing and developing an analysis workflow, not to replace all professional judgment. A more reliable path for quantitative analysis and research-report automation is to let the model handle task understanding, code organization, and written expression; let deterministic programs handle calculation; and let data and evidence validate the conclusions.
