ai-hedge-fund股票系统:
https://github.com/virattt/ai-hedge-fund
镜像地址: https://gitcode.com/gh_mirrors/ai/ai-hedge-fund
项目地址: https://gitee.com/pythonstock/docker-run-ai-hedge-fund
这是一个基于人工智能的对冲基金的原理验证项目。本项目旨在探讨利用人工智能进行交易决策的可能性。本项目仅供教育用途,不适用于实际交易或投资。
估计是全网首个,将人工智能对冲基金ai-hedge-fund 转换中文结果,接入deepseek大模型股票分析,仅演示视频
该系统采用了多个协同工作的智能体:
本杰明·格雷厄姆智能体 - 价值投资的鼻祖,只购买具有安全边际的隐藏宝石比尔·阿克曼智能体 - 积极投资者,采取大胆立场并推动变革凯西·伍德智能体 - 增长投资的皇后,坚信创新和颠覆的力量查理·芒格智能体 - 沃伦·巴菲特的搭档,只以公平价格购买卓越的企业迈克尔·伯里智能体 - 《大空头》中的逆向投资者,搜寻深度价值彼得·林奇智能体 - 务实投资者,在日常业务中寻找“十倍股”菲利普·费舍尔智能体 - 细心的增长投资者,运用深入的“小道消息”研究斯坦利·德鲁肯米勒智能体 - 宏观传奇,寻找具有增长潜力的不对称机会沃伦·巴菲特智能体 - 奥马哈的先知,寻求公平价格的卓越公司估值智能体 - 计算股票的内在价值并生成交易信号情绪智能体 - 分析市场情绪并生成交易信号基本面智能体 - 分析基本面数据并生成交易信号技术分析智能体 - 分析技术指标并生成交易信号风险管理员 - 计算风险指标并设置头寸限制投资组合经理 - 作出最终交易决策并生成订单
2,需要汉化的文件
main.py
src/agents/portfolio_manager.py src/agents/risk_manager.py
汉化一个策略 src/agents/warren_buffett.py
展示使用 src/utils/display.py src/utils/llm.py
3,运行效果
# python main.py --ticker NVDA --show-agent-graph
? 选择您的 AI 分析师。 [沃伦·巴菲特]
选定的分析师:Warren Buffett
? 选择您的 LLM 模型: [deepseek] deepseek-v3
选定的 DeepSeek 模型:deepseek-chat
/usr/local/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:623: UserWarning:
warn(
⋯ Warren Buffett [NVDA] 已完成
⋯ Risk Management [NVDA] 完成
⋯ Portfolio Management[NVDA] 生成交易决策
分析报告 - NVDA
==================================================
代理方分析 - NVDA
+----------------+---------+--------+------------------------------------------------------------+
| 代理方 | 信号 | 信心 | 推理 |
+================+=========+========+============================================================+
| Warren Buffett | BEARISH | 80.0% | NVDA的财务表现确实令人印象深刻,ROE高达115.4% |
| | | | ,债务水平保守,经营利润率强劲。这让我想起了我们投资可口可 |
| | | | 乐时的情景,当时我们也看到了类似的财务稳健性。然而,当前的 |
| | | | 估值让我感到不安。价格与账面价值比高达44.03,自由现金 |
| | | | 流收益率仅为1.7%,这意味着投资者为每一美元的收益支付了 |
| | | | 过高的价格。此外,内在价值分析显示安全边际为-54.6%, |
| | | | 这与我们坚持的‘以显著折扣买入’原则相悖。虽然NVDA拥有 |
| | | | 强大的经济护城河和优秀的管理团队,但目前的股价已经远远超出 |
| | | | 了其内在价值。就像我们过去避免投资过热科技股一样,现在对N |
| | | | VDA保持谨慎是明智的。 |
+----------------+---------+--------+------------------------------------------------------------+
交易决策 - NVDA
+------+----------------------------------------------------------+
| 操作 | SHORT |
+------+----------------------------------------------------------+
| 数量 | 171 |
+------+----------------------------------------------------------+
| 信心 | 80.0% |
+------+----------------------------------------------------------+
| 推理 | NVDA的财务表现确实令人印象深刻,ROE高达115.4% |
| | |
| | ,债务水平保守,经营利润率强劲。这让我想起了我们投资可口 |
| | 可 |
| | 乐时的情景,当时我们也看到了类似的财务稳健性。然而,当 |
| | 前的 |
| | 估值让我感到不安。价格与账面价值比高达44.03,自 |
| | 由现金 |
| | 流收益率仅为1.7%,这意味着投资者为每一美元的收 |
| | 益支付了 |
| | 过高的价格。此外,内在价值分析显示安全边际为-5 |
| | 4.6%, |
| | 这与我们坚持的‘以显著折扣买入’原则相悖。虽然 |
| | NVDA拥有 |
| | 强大的经济护城河和优秀的管理团队,但目前的股 |
| | 价已经远远超出 |
| | 了其内在价值。就像我们过去避免投资过热科技 |
| | 股一样,现在对N |
| | VDA保持谨慎是明智的。 |
+------+----------------------------------------------------------+
对比之前的英文效果:
运行:
python3 src/main.py --ticker AAPL,MSFT,NVDA
? Select your AI analysts. [Ben Graham]
Selected analysts: Ben Graham
? Select your LLM model: [deepseek] deepseek-v3
Selected DeepSeek model: deepseek-chat
✓ Ben Graham [NVDA] Done
✓ Risk Management [NVDA] Done
✓ Portfolio Management[NVDA] Done
Analysis for AAPL
==================================================
AGENT ANALYSIS: [AAPL]
+------------+----------+--------------+--------------------------------------------------------------+
| Agent | Signal | Confidence | Reasoning |
+============+==========+==============+==============================================================+
| Ben Graham | NEUTRAL | 45.0% | While AAPL demonstrates positive and growing EPS across all |
| | | | periods, indicating stable earnings, its financial strength |
| | | | metrics fall short of Graham's conservative standards. The |
| | | | current ratio of 0.87 is significantly below Graham's |
| | | | preferred threshold of 1.5, reflecting weaker liquidity, and |
| | | | the debt ratio of 0.84 is quite high by Graham's standards, |
| | | | suggesting excessive leverage. Additionally, the stock |
| | | | trades at a substantial premium to its Graham Number of |
| | | | $22.59, with a negative margin of safety of -88.39%, |
| | | | offering no margin of safety. Although the company has a |
| | | | consistent dividend record, the combination of weak |
| | | | liquidity, high leverage, and overvaluation relative to |
| | | | Graham's intrinsic value metrics warrants a neutral stance. |
+------------+----------+--------------+--------------------------------------------------------------+
TRADING DECISION: [AAPL]
+------------+--------------------------------------------------------------+
| Action | HOLD |
+------------+--------------------------------------------------------------+
| Quantity | 0 |
+------------+--------------------------------------------------------------+
| Confidence | 45.0% |
+------------+--------------------------------------------------------------+
| Reasoning | Neutral signal with low confidence, no existing positions to |
| | manage |
+------------+--------------------------------------------------------------+
Analysis for MSFT
==================================================
AGENT ANALYSIS: [MSFT]
+------------+----------+--------------+-------------------------------------------------------------+
| Agent | Signal | Confidence | Reasoning |
+============+==========+==============+=============================================================+
| Ben Graham | NEUTRAL | 50.0% | MSFT exhibits stable earnings growth with positive EPS in |
| | | | all periods, which aligns with Graham's preference for |
| | | | earnings consistency. The company's financial strength is |
| | | | moderate, with a current ratio of 1.27 (below Graham's |
| | | | preferred 2.0 threshold) but a conservative debt ratio of |
| | | | 0.48 (under Graham's 0.50 limit). However, the valuation |
| | | | presents no margin of safety, with the Graham Number at |
| | | | $98.19 and the current price trading at a 73.31% premium, |
| | | | far exceeding Graham's strict criteria for intrinsic value. |
| | | | The dividend history provides some cushion, but the lack of |
| | | | a margin of safety and weaker liquidity metrics necessitate |
| | | | a neutral stance. |
+------------+----------+--------------+-------------------------------------------------------------+
TRADING DECISION: [MSFT]
+------------+------------------------------------------------------+
| Action | HOLD |
+------------+------------------------------------------------------+
| Quantity | 0 |
+------------+------------------------------------------------------+
| Confidence | 50.0% |
+------------+------------------------------------------------------+
| Reasoning | Neutral signal with moderate confidence, no existing |
| | positions to manage |
+------------+------------------------------------------------------+
Analysis for NVDA
==================================================
AGENT ANALYSIS: [NVDA]
+------------+----------+--------------+--------------------------------------------------------------+
| Agent | Signal | Confidence | Reasoning |
+============+==========+==============+==============================================================+
| Ben Graham | NEUTRAL | 50.0% | NVDA demonstrates strong financial strength with a current |
| | | | ratio of 4.44 (well above Graham's preferred 2.0 threshold) |
| | | | and a conservative debt ratio of 0.29 (below Graham's 0.50 |
| | | | limit). The company has consistently positive and growing |
| | | | EPS, and it pays dividends, adding an extra layer of safety. |
| | | | However, the valuation metrics present a significant |
| | | | concern. The stock trades at a steep premium to both its |
| | | | Graham Number ($14.69 vs. $101.12 market price, -85.47% |
| | | | margin of safety) and its NCAV per share ($1.95 vs. |
| | | | $101.12). While the financial strength and earnings |
| | | | stability are commendable, the extreme overvaluation |
| | | | relative to Graham's conservative metrics prevents a bullish |
| | | | recommendation. A neutral stance is warranted until the |
| | | | price aligns more closely with intrinsic value. |
+------------+----------+--------------+--------------------------------------------------------------+
TRADING DECISION: [NVDA]
+------------+------------------------------------------------------+
| Action | HOLD |
+------------+------------------------------------------------------+
| Quantity | 0 |
+------------+------------------------------------------------------+
| Confidence | 50.0% |
+------------+------------------------------------------------------+
| Reasoning | Neutral signal with moderate confidence, no existing |
| | positions to manage |
+------------+------------------------------------------------------+
PORTFOLIO SUMMARY:
+----------+----------+------------+--------------+
| Ticker | Action | Quantity | Confidence |
+==========+==========+============+==============+
| AAPL | HOLD | 0 | 45.0% |
+----------+----------+------------+--------------+
| MSFT | HOLD | 0 | 50.0% |
+----------+----------+------------+--------------+
| NVDA | HOLD | 0 | 50.0% |
+----------+----------+------------+--------------+
Portfolio Strategy:
Neutral signal with low confidence, no existing positions to
manage
处理中文换行的问题:
同时在python 中,处理英文的换行和中文的是不一样的。:
这样处理中文的换行:
max_line_length = 30 #60
# 特殊处理中文
characters = [char for char in reasoning_str]
for word in characters: #reasoning_str.split():
if len(current_line) + len(word) + 1 > max_line_length:
wrapped_reasoning += current_line + "\n"
current_line = word
else:
if current_line:
current_line += word
else:
current_line = word
if current_line:
wrapped_reasoning += current_line
next 汉化替换 api 接口
实现a股票分析
akshare https://akshare.akfamily.xyz/introduction.html