Abstract
Developing new portfolio-management algorithms typically demands substantial programming effort, limiting rapid experimentation and excluding finance professionals without coding skills. Current robo-advisory tools offer pre-built but rigid strategies, restricting customization and experimentation. We introduce PortfolioPilot, an open-source, agentic platform that enables users to generate bespoke portfolio through natural-language descriptions. Leveraging the Anthropic Claude API, PortfolioPilot dynamically synthesizes executable TypeScript algorithms that run in the frontend with security validation. The system integrates real-time backtesting with historical market data, classical optimization algorithms (Markowitz, LSTM, ARIMA), and interactive performance visualizations.
Introduction
Developing algorithmic portfolio management strategies typically requires a dual skill set: deep financial knowledge and advanced programming proficiency. This requirement creates a significant barrier to entry for many finance professionals. Existing solutions generally fall into two categories: rigid robo-advisors that offer user-friendly but limited templates, and flexible research environments (like custom Python scripts) that require extensive coding effort, slowing down the "idea-to-evaluation" cycle.
PortfolioPilot addresses this "accessibility gap" by providing a system where users can describe a strategy in natural language—such as "a momentum strategy on tech stocks with monthly rebalancing"—and have the platform automatically generate, validate, and backtest the underlying code.
System Architecture
PortfolioPilot utilizes a dual-path architecture to balance flexibility and performance, as illustrated in the system overview below.
The AI Path (Strategy Generation)
When a user describes a custom strategy, the system uses a Next.js API route to wrap the description in a domain-specific prompt. This is sent to the Anthropic Claude API, which returns executable TypeScript code. To ensure safety, the platform employs multi-layered security checks, sanitizing unsafe patterns and validating function signatures before execution in the user's browser.
The Classical Path (Built-in Models)
For standard approaches, the platform provides a library of "canonical" models, including Markowitz Mean-Variance Optimization, GMVP, ARIMA, LSTM, and Autoformer. These models run on a Python backend (FastAPI) using standard libraries like PyTorch and Pandas.
Unified Engine and Persistence
Both paths feed into a unified forecasting and backtesting engine. This engine retrieves historical data for DOW30 tickers via the YFinance API, simulates trades over a rolling window, and calculates performance metrics like the Sharpe ratio and maximum drawdown. A "History" interface backed by Supabase allows users to revisit and refine past strategies, treating development as an iterative research process.
Results and Evaluation
The platform demonstrates high performance and functional versatility. Key results include:
- Low Latency: The system generates new strategies in under one second and completes complex rolling-window evaluations in under three seconds on a modest four-core CPU server.
- Functional Versatility: The AI successfully implements foundational strategies like momentum, mean reversion, and risk parity without manual coding.
- Robustness: Unit tests confirmed that generated TypeScript functions consistently produced valid weight vectors and respected user-defined risk constraints.
Conclusion and Future Work
PortfolioPilot represents a significant step toward democratizing quantitative finance. While currently limited to a subset of DOW30 tickers and stock assets, future work aims to expand the asset scope to include options and derivatives. Additionally, the authors plan to support open-source LLMs like LLaMA and Qwen for private deployments and implement collaborative tools for strategy sharing.
Source Code: https://github.com/JarudeC/portfoliopilot
Summary updated