StockBench is a comprehensive benchmark platform designed to evaluate Large Language Models (LLMs) in stock trading decision-making. It simulates real-world trading scenarios using historical market data to assess investment decision quality, risk management capabilities, and return performance across different LLM models.
- 🌍 Realistic Market Interaction - Curated stocks with high-quality price, fundamental data, and timely news from Polygon & Finnhub
- 🔄 Continuous Decision Making - Multi-step workflow (portfolio → analysis → trade) reflecting real investor behavior
- 🔒 Data Contamination Free - Recent market data (post-2024) with zero overlap with LLM training corpora
# Clone the repository
git clone <repository-url>
cd stockbench
# Create environment
conda create -n stockbench python=3.11
conda activate stockbench
# Install dependencies
pip install -r requirements.txtSet up your API keys:(If you need to test other months or stocks, please set it up)
export POLYGON_API_KEY="your_polygon_api_key"
export FINNHUB_API_KEY="your_finnhub_api_key"
export OPENAI_API_KEY="your_openai_api_key"💡 Tip: Free tiers available at Polygon.io and Finnhub.io
Edit scripts/run_benchmark.sh to configure your backtest:
START_DATE="${START_DATE:-2025-03-01}"
END_DATE="${END_DATE:-2025-06-30}"
LLM_PROFILE="${LLM_PROFILE:-openai}"Then run:
bash scripts/run_benchmark.shOr use command-line arguments:
bash scripts/run_benchmark.sh \
--start-date 2025-04-01 \
--end-date 2025-05-31 \
--llm-profile deepseek-v3.1Backtest results are automatically saved in storage/reports/backtest/ with comprehensive metrics:
Performance Metrics
- Total Return
- Sortino Ratio
- Maximum Drawdown
Extend the platform with your own trading strategies by implementing custom agents.
stockbench/
├── stockbench/ # Core package
│ ├── agents/ # Trading agents
│ ├── backtest/ # Backtesting engine
│ ├── adapters/ # Data adapters
│ └── apps/ # Applications
├── scripts/ # Run scripts
├── storage/ # Data storage & reports
└── config.yaml # Configuration file
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
- Polygon.io - High-quality stock market data
- Finnhub - Financial news and market data
- OpenAI - Powerful LLM capabilities
- All contributors to this project
- 🐛 Issues: GitHub Issues
⭐ If this project helps you, please give us a Star!
Made with ❤️ by StockBench Team

