Inspiration

Quantitative finance questions look simple and are easy to get subtly wrong. "How much would a 10-year bond lose if rates rose by one percentage point?" depends on a day-count convention, a compounding choice and a correct duration formula; "How volatile was EUR/USD?" depends on annualization, return definitions and how missing days are handled. General-purpose coding agents write plausible code for these questions, but plausible is not enough: a percent where a decimal was expected, a sign error in an option value or a call to a removed pandas argument makes the whole answer wrong.

We wanted an agent that answers quant questions the way a careful analyst would: look at the data first, use the right method and convention, check the result against financial identities, and say clearly what it found. We also wanted to show that an open-weight model can do this well when it is given the right knowledge and checks.

What it does

Lamuir is an AI coding agent for quantitative finance. Given a question in plain English and the relevant data, it profiles the data, writes and executes Python in a sandbox, validates the results against financial invariants and the requested output format, and corrects the errors it detects. It delivers the code, result files, tables, plots and a short written explanation.

When a question comes without data, the source finder uses Tavily to search official sites (U.S. Treasury, ECB, SEC), lets Nemotron pick a registered source, downloads the data from its official endpoint, and records each file's URL, download time and SHA-256 hash.

On QF-Bench, a public quantitative finance coding benchmark, Lamuir reaches 75.6% pass@1 (65 of 86 tasks, one run each) with the open-weight NVIDIA Nemotron 3 Super 120B on Nebius Token Factory. The top entry on the official QF-Bench leaderboard is 61.7% (GPT-5.5 with Codex CLI).

To make its analysis and code more reliable, Lamuir provides the model with structured finance knowledge, algorithmic guidance, and API references that match the installed library versions. It is designed to be extended without changing the agent itself: new data sources can be registered with the source finder, new methods and algorithms added as knowledge cards, and references added for new versions of pandas, NumPy, SciPy, arch and other quantitative finance libraries.

How we built it

  • Model. All reasoning and code come from NVIDIA Nemotron 3 Super 120B (12B active parameters), served through the Nebius Token Factory OpenAI-compatible API at temperature 0 with reasoning enabled.
  • Foundation. Lamuir started from the open-source mini-swe-agent and substantially modified its agent loop, replacing its shell with a persistent Python session (a REPL). Everything else is our own design.
  • Sandbox. The agent runs in a Docker container and executes Python one cell at a time in a persistent session, inspecting the output of each step before writing the next.
  • Data profile. Before the first model request, Lamuir reads the input files in full and reports facts only: duplicated rows, missing or non-numeric cells, extreme values, date ranges and duplicate dates.
  • Knowledge cards with RAG. More than 200 finance, algorithm and coding cards cover methods, market conventions and library APIs. They are indexed as 948 retrievable chunks, and retrieval-augmented generation (RAG) adds the relevant ones to the model's context for each question: method and convention cards are matched to the question's terms, library reference cards are ranked with BM25, and a second retrieval pass adds library usage notes for the functions in use, within a fixed context budget. Each method card states the method's purpose, when to use it, how to implement it, its limits and a computable cross-check. 45 API cards contain the official docstrings of the installed pandas, NumPy, SciPy and arch functions, so the model sees the exact signatures of the versions it is running.
  • Output requirements. Lamuir reads the expected files, columns, units, date formats and decimal places from the question, and helper functions write files that follow them.
  • Result checks. Before results are accepted, Lamuir verifies that all required files and fields are present, that the format matches, and that values satisfy financial invariants: non-negative option values, probabilities within [0, 1], non-negative volatilities and integer counts. A definite violation goes back to the model with the field and value.
  • Source finder. Tavily search restricted to official domains, Nemotron for source selection with strict JSON, and a dedicated download adapter per source.
  • Generalization.We improved Lamuir step by step, testing each change on QF-Bench. To keep it from overfitting to the benchmark and make it robust to unseen tasks, we also tested changes on variant tasks we wrote ourselves, with different data, parameters and wording. We avoid hardcoding task-specific rules and keep its finance knowledge, agent harness and result checks general.
  • Demo cases.To show Lamuir at work beyond the benchmark, we also built six demo cases on public data, each with an independent reference solution. Their recorded runs can be replayed on our demo page.

Challenges we ran into

  • Almost right is still wrong. Our agent passed over 93% of individual tests while solving a much smaller share of whole tasks. Most remaining failures were not wrong methods but small details: units, scales, key names, date formats or conventions. This is why the output requirements and result checks became core parts of the design.
  • Library versions. The model often wrote code for older or newer versions of pandas, NumPy or SciPy than the ones installed. We addressed this from two sides: API cards built from the installed docstrings, and 62 rules that attach a one-line fix when a known version error occurs.
  • Run-to-run variation. Even at temperature 0, outputs are not fully deterministic, so a single pass or fail can be misleading. We learned to judge changes on repeated runs and failure patterns, not on one result.
  • Improvements vs. regressions. Many promising changes fixed one task but caused regressions on others. We kept every run, including failed ones, and resolved these cases, for example by finding a general design that works for both tasks, or by defining clear boundaries for when each approach applies.
  • Trustworthy data. Answers are only as good as their inputs, so the source finder downloads only from official endpoints and records the provenance of every file.

Accomplishments that we're proud of

  • 75.6% pass@1 on QF-Bench with an open-weight 120B model, above the 61.7% top entry on the official leaderboard.
  • An end-to-end path from a plain-English question to official data, verified code, results and a written explanation, with the provenance of every input file recorded.
  • Full transparency: all demo runs are published in the repository.

What we learned

  • For quantitative finance, the bottleneck is less often the model's reasoning than conventions, units and output details. Retrieving explicit knowledge with RAG and adding automatic checks closes much of that gap.
  • An open-weight model with the right context and verification can compete with much larger proprietary systems.
  • Giving the model the exact documentation of the installed libraries is more effective than hoping it remembers the right API version.
  • Honest evaluation matters: single runs vary, held-out questions reveal things a benchmark does not, and failed runs are as informative as successful ones.

What's next for Lamuir

  • More data sources. Register more official sources in the source finder, such as central banks, statistical agencies and exchange data.
  • Broader knowledge. Add knowledge cards for more methods, trading strategies and asset classes, and API references for more quantitative finance libraries and newer library versions, without changing the agent.
  • More stable results. Reduce run-to-run variation, for example by combining multiple runs or adding further cross-checks.
  • Easier use. Let users ask a question directly from the command line or a web interface, without preparing a folder first.

Built With

Share this project:

Updates

Submission history