
AI Hedge Fund
CLI模拟对冲基金的多 Agent 系统:巴菲特、芒格等投资风格 Agent 与量化、风控模块共同分析个股并可回测,适合金融课堂演示与学习投资框架。首次运行时填入 Financial Datasets 与模型 API Key;不做真实交易,结论需专业人员复核。
AI Hedge Fund
This is a proof of concept for an AI-powered hedge fund. The goal of this project is to explore the use of AI to make trading decisions. This project is for educational purposes only and is not intended for real trading or investment.
Note: the system does not actually make any trades.
Disclaimer
This project is for educational and research purposes only.
- Not intended for real trading or investment
- No investment advice or guarantees provided
- Creator assumes no liability for financial losses
- Consult a financial advisor for investment decisions
- Past performance does not indicate future results
By using this software, you agree to use it solely for learning purposes.
How to Install
pipx install aihf
(or uv tool install aihf, or pip install aihf into an environment of your choice)
Then run it from anywhere:
aihf
API keys
The app asks for keys the first time it needs them and saves them to ~/.hedge-fund/.env — nothing to configure up front. It needs:
- A Financial Datasets API key, for prices, fundamentals, and earnings.
- One model API key for the investor agents. Supported providers: Anthropic, OpenAI, DeepSeek, Google, xAI, Kimi, TypeSafe (Jev).
Keys exported in your shell always win over the saved file.
How to Run
Interactive app
aihf
With no arguments, this launches the interactive terminal app. Build a fund — pick stocks, strategies, rebalance cadence — or backtest a saved fund and watch its equity curve draw against its benchmark. Funds you build are saved as mandate files in ~/.hedge-fund/mandates/.
Non-interactive
Run one fund cycle from a mandate file. The full cycle record prints to stdout as JSON; a short human summary goes to stderr:
aihf ~/.hedge-fund/mandates/example.yaml --tickers AAPL,MSFT
Run the same mandate with Jev after configuring TYPESAFE_API_KEY:
aihf ~/.hedge-fund/mandates/example.yaml --tickers AAPL,MSFT --model jev-1.13.0
Backtest the mandate over history at its rebalance cadence:
aihf ~/.hedge-fund/mandates/example.yaml --tickers AAPL,MSFT --backtest
An LLM trained after your backtest window may remember how those companies did, and that memory would score as skill. So a backtest withholds the ticker, industry and calendar dates from the investor agents' prompts; the personas see the fundamentals with periods labelled t-0, t-1, ... instead. This reduces the recall without removing it (distinctive numbers can still give a large company away), and a window after the model's training cutoff is the cleanest read. Live runs are unaffected and name the company.
A mandate is the desk — strategies, staff, risk, capital, cadence — and never names tickers; --tickers says what to point it at for this run.
Development
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund
poetry install
poetry run aihf
poetry run pytest hedge_fund
How to Contribute
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Important: Please keep your pull requests small and focused. This will make it easier to review and merge.
Feature Requests
If you have a feature request, please open an issue and make sure it is tagged with enhancement.
License
This project is licensed under the MIT License - see the LICENSE file for details.
相关资源

TradingAgents
CLI多智能体投研框架:基本面、情绪、新闻、技术分析师与多空研究员、交易员、风控分工辩论,对指定股票输出研报与评级,支持美股、港股与 A 股。需 Python 环境和任一大模型 API Key;不构成投资建议,结论需专业人员复核。
TauricResearch/TradingAgents110k
TradingAgents-Astock
CLITradingAgents 的 A 股特化版:接入通达信、东财、新浪等免费行情源,新增政策、游资、解禁分析师,按 T+1 与涨跌停规则输出中文研报。需 Python 环境与 DeepSeek 等模型 API Key;不构成投资建议,结论需专业人员复核。
simonlin1212/TradingAgents-astock3.6k
Dexter
CLI金融研究终端 Agent(金融研究版 Claude Code):把公司研究问题拆成步骤,自动拉取财报与行情数据并自我校验后作答。需安装 Bun,准备模型 API Key 与 Financial Datasets API Key;仅供学习研究,结论需专业人员复核。
virattt/dexter27.6k
hithink-finance CLI(同花顺金融数据)
CLI同花顺官方金融数据命令行:查询 A 股行情、财务报表、估值、公募基金与期货期权数据,可把全市场历史行情同步到本地 DuckDB 用 SQL 分析。需要 Node.js 22+ 和在同花顺金融数据服务官网申请的 API Key;数据仅供研究,投资决策需专业人员复核。
HiThink-Tech/Financial-API3.9k
Longbridge Terminal
CLI长桥证券官方命令行,可查港美股实时行情、K 线、期权与窝轮、个股新闻与公告、账户持仓与资金,也能下单(默认只预览,确认后才执行);命令都能输出 JSON,便于 agent 整理投研材料。需长桥证券账户并在浏览器登录授权;分析结论需专业人员复核。
longbridge/longbridge-terminal1k
FRED MCP Server
MCP接入美联储圣路易斯分行的 FRED 经济数据库,按关键词检索并提取 80 多万条宏观时间序列(GDP、失业率、通胀、利率等),可直接换算同比、环比,适合宏观研究、投资分析与经济学教学。需免费申请 FRED API Key 并装好 Node.js。
stefanoamorelli/fred-mcp-server124