
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. Or, instead of a key, the private key of a Base wallet holding USDC: every call then pays for itself with x402 (
pip install 'aihf[x402]'; last 365 days of data, non-professional use). - 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. It has two modes:
- Paper trading — your funds, each with a ledger of real market days and fake money. Highlight a fund to see what its next run will do; press enter to run it through the next completed session (an approval step shows the exact decision about to execute before anything trades),
sfor its full session history,h/rfor the kill switch. Build a new fund from the same list: strategies, capital, cadence, tickers, and it is live. Every session is appended to a hash-chained ledger in~/.hedge-fund/paper/<name>/, so NAV is a track record, not a reset. - Backtesting — replay a fund over history and watch its equity curve draw against its benchmark. Results are saved to
~/.hedge-fund/research/. Fund definitions live in~/.hedge-fund/mandates/and carry no tickers; you pick the universe per backtest.
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/TradingAgents124k
TradingAgents-Astock
CLITradingAgents 的 A 股特化版:接入通达信、东财、新浪等免费行情源,新增政策、游资、解禁分析师,按 T+1 与涨跌停规则输出中文研报。需 Python 环境与 DeepSeek 等模型 API Key;不构成投资建议,结论需专业人员复核。
simonlin1212/TradingAgents-astock4.1k
Dexter
CLI金融研究终端 Agent(金融研究版 Claude Code):把公司研究问题拆成步骤,自动拉取财报与行情数据并自我校验后作答。需安装 Bun,准备模型 API Key 与 Financial Datasets API Key;仅供学习研究,结论需专业人员复核。
virattt/dexter28k
hithink-finance CLI(同花顺金融数据)
CLI同花顺官方金融数据命令行:查询 A 股行情、财务报表、估值、公募基金与期货期权数据,可把全市场历史行情同步到本地 DuckDB 用 SQL 分析。需要 Node.js 22+ 和在同花顺金融数据服务官网申请的 API Key;数据仅供研究,投资决策需专业人员复核。
HiThink-Tech/Financial-API4.7k
Longbridge Terminal
CLI长桥证券官方命令行,可查港美股实时行情、K 线、期权与窝轮、个股新闻与公告、账户持仓与资金,也能下单(默认只预览,确认后才执行);命令都能输出 JSON,便于 agent 整理投研材料。需长桥证券账户并在浏览器登录授权;分析结论需专业人员复核。
longbridge/longbridge-terminal1.1k
FRED MCP Server
MCP接入美联储圣路易斯分行的 FRED 经济数据库,按关键词检索并提取 80 多万条宏观时间序列(GDP、失业率、通胀、利率等),可直接换算同比、环比,适合宏观研究、投资分析与经济学教学。需免费申请 FRED API Key 并装好 Node.js。
stefanoamorelli/fred-mcp-server135