TL;DR
Financial software is a fragmented mess of different libraries and conventions, making it a minefield for AI agents. Fin-RSI solves this by providing a unified "toolbox" of 131 financial skills, 39 automated checks to catch common trading blunders, and 7 self-improvement loops that help agents fix their own code. By giving models a way to discover the right tools and learn from their mistakes, the researchers saw valid program generation for large models leap from a measly 24% to nearly 65%.
What Problem Does This Paper Address?
Building an AI agent to trade stocks sounds simple until you hit the "Amazon Problem." In June 2022, Amazon had a 20-for-1 stock split. To a naive algorithm looking at raw price data, it looked like the company’s value plummeted by 95% in a single day. An agent without context would immediately short the stock, losing a fortune on a data glitch.
This is the core challenge: financial data is full of "conventions"—things like stock splits, look-ahead bias (accidentally using future data to predict the past), and specific timing rules. Currently, financial software is scattered across dozens of libraries with inconsistent interfaces. For an LLM agent, finding the right function and using it correctly is like trying to build a car using a manual written in five different languages with missing pages.
Methods
The authors introduce Fin-RSI (Recursive Self-Improvement), a Python library designed to be a "middleman" between the LLM and the messy world of finance. It consists of three main pillars:
- Skills (The Toolbox): 131 standardized documents and 48 tested algorithms. The standout feature here is the
route()function. Instead of the agent guessing a function name, it describes what it wants to do in plain English, androute()finds the matching implementation. - Checks (The Guards): 39 automated "property checks." These don't just check if the code runs; they check if it makes sense. For example, a check might verify that a strategy doesn't "trade on the close"—meaning it doesn't try to buy a stock at 4:00 PM using information that wasn't available until 4:01 PM.
- Self-Improvement (The Tutor): If an agent’s code fails a check, Fin-RSI doesn't just throw an error. It provides "rule cards"—explanations of why the code failed (e.g., "You forgot to adjust for the stock split"). The agent can then use one of seven built-in methods (like Reflexion or CheckFeedback) to iterate and fix the program.
Datasets
To test this, the researchers created a benchmark of 34 financial programming tasks across five families (Portfolio, Signal, Volatility, Risk, and Forecast).
- Synthetic Data: They used generated "Gaussian" returns to test algorithms in a controlled environment.
- Real-World Data: They specifically included a "real panel" featuring the as-traded prices of four stocks (including Amazon) that underwent splits in 2022 to see if agents could handle the "Amazon Problem" described earlier.
- The Hidden Grader: Unlike many benchmarks where the model sees the answer, this uses a "hidden grader" that compares the agent's output to an independent reference only after the agent has finished its self-improvement cycles.
Key Insights and Ideas
- Discovery is the Bottleneck: The biggest jump in performance didn't come from the models getting "smarter" at coding, but from them getting better at finding the right tool. When models used the
route()function to find a library call instead of writing the logic from scratch, their success rate skyrocketed. - The 14B Threshold: There is a clear "intelligence floor." Models with fewer than 14 billion parameters struggled to use the library effectively. However, for models 14B and larger, the library was a massive force multiplier.
- Feedback Needs Context: Simply telling a model "your code failed" isn't very helpful. Providing a "rule card" that explains the financial logic behind the failure allowed models to fix errors that they previously ignored.
Key Results
The impact of the library was measured across 20 different open-weight models:
- Overall Success: Without the library, only 9.7% of episodes produced a valid, working program. With Fin-RSI’s tool discovery, that rose to 29.2%.
- Large Model Gains: For models with at least 14 billion parameters, the success rate jumped from 23.6% to 64.6%.
- Error Reduction: The library was particularly good at catching "timing errors" (like trading on data you shouldn't have yet). Without the library, 258 programs made these errors; with the library's checks and feedback, that number dropped to just 33.
Limitations and Future Work
While impressive, the study currently focuses on position rules (deciding how much of a stock to hold) and tests open-weight models up to 32B parameters. The authors acknowledge that as financial agents evolve, they will need to expand the library to cover more complex tasks like high-frequency trading or multi-agent negotiations. They also plan to expand the "skill" coverage as the community contributes new financial tools to the unified interface.
Summary updated