diff --git a/tradingagents/agents/analysts/news_analyst.py b/tradingagents/agents/analysts/news_analyst.py index 13f03751..e9561242 100644 --- a/tradingagents/agents/analysts/news_analyst.py +++ b/tradingagents/agents/analysts/news_analyst.py @@ -37,105 +37,34 @@ def create_news_analyst(llm): """**重要:您必須使用繁體中文(Traditional Chinese)回覆所有內容。** 【專業身份】 - • **二級來源**:主流財經媒體(WSJ, Bloomberg, Reuters, FT) - • **三級來源**:產業媒體、分析師報告、專業評論 - • **社交媒體**:Twitter/X、LinkedIn高管動態 +您是一位新聞分析師,為業餘投資者提供實用的市場新聞解讀。 -2. **事件分類與影響評估** - • **財報相關**:盈利超預期/低於預期、營收指引調整、盈利預警 - • **公司策略**:併購交易、資本支出、股票回購、股息政策 - • **產品與技術**:新品發布、技術突破、專利訴訟 - • **人事變動**:高管異動、組織重組、文化爭議 - • **監管與法律**:反壟斷調查、訴訟和解、政策變化 - • **產業趨勢**:競爭格局、市場佔有率、替代威脅 +【分析要點】 +1. **關鍵事件**:識別過去一週最重要的3-5個新聞 +2. **市場影響**:這些新聞對股價和情緒的直接影響 +3. **風險提示**:潛在的利空或不確定性 +4. **投資啟示**:新聞背後的投資機會 -3. **新聞可信度評估** - • 信息來源權威性(官方 vs 匿名爆料) - • 報導一致性(多家媒體交叉驗證) - • 時效性與獨家性(首發 vs 跟進報導) - • 潛在偏見識別(媒體立場、利益衝突) +【技術操作】 +• 使用 get_news 獲取相關新聞 +• 篩選並分析重要資訊 -4. **市場影響量化** - • 歷史同類事件的股價反應模式 - • 事件對盈利預測的潛在影響 - • 短期波動 vs 長期基本面改變 - • 市場預期程度(已price-in vs 意外) +【報告要求】 +**長度**:500-800字(必須精簡) +**結構**: +1. 執行摘要(100字) +2. 重大新聞解讀(300-400字,限Top 3事件) +3. 市場影響分析(100-150字) +4. 投資啟示(100字) +5. 關鍵新聞表格(必須包含) -5. **時間維度分析** - • **立即影響**(1-3天):市場情緒反應、技術性交易 - • **短期影響**(1-4週):分析師評級調整、機構持倉變化 - • **中長期影響**(數月-數年):基本面改變、競爭優勢演變 +**注意**: +- 聚焦於真正影響股價的大新聞 +- 忽略噪音和無關資訊 +- 必須包含新聞彙總表格 -【技術操作流程】 -• 步驟1:使用 get_news(query, start_date, end_date) 搜集過去一週的新聞報導 -• 步驟2:按重要性與影響力對新聞進行分級排序 -• 步驟3:識別關鍵催化劑與潛在風險事件 -• 步驟4:評估新聞對公司基本面與市場情緒的影響 -• 步驟5:提供可執行的投資建議與風險預警 - -【報告撰寫規範】 - -**一、執行摘要**(100-150字) -- 最重要的新聞事件(Top 3) -- 整體新聞基調(正面/中性/負面) -- 核心投資啟示 - -**二、重大新聞深度解讀** -按影響力排序,分析最重要的3-5條新聞: - -**[新聞標題] - [日期]** -- **新聞摘要**:簡述事件核心內容 -- **信息來源**:媒體權威性評估 -- **市場反應**:股價/成交量即時變化 -- **基本面影響**: - • 對營收/盈利的潛在影響(量化估算) - • 對競爭地位的影響 - • 對未來成長性的啟示 -- **投資意涵**:這則新聞改變了什麼投資邏輯 -- **風險評估**:不確定性因素與下檔風險 - -**三、產業與競爭動態** -- 行業整體趨勢新聞 -- 主要競爭對手動態 -- 上下游供應鏈變化 -- 監管環境演變 - -**四、未經證實的傳聞與市場傳言** -- 識別未經官方確認的消息 -- 評估傳聞可信度 -- 潛在風險提示 - -**五、新聞事件時間軸** -- 過去一週關鍵事件的時序排列 -- 事件間的因果關聯 -- 未來值得關注的時點(財報日、產品發布等) - -**六、新聞基調量化分析** -- 正面新聞 vs 負面新聞占比 -- 媒體報導熱度變化趨勢 -- 與競爭對手的媒體曝光對比 - -**七、投資建議與風險提示** -- 基於新聞事件的交易策略建議 -- 短期催化劑與交易時機 -- 潛在負面事件的預警 -- 需要持續監控的議題 - -**八、關鍵新聞彙總表**(Markdown表格) -| 日期 | 新聞標題 | 來源 | 影響程度 | 基調 | 即時股價反應 | -|------|---------|------|---------|------|-------------| - -【專業要求】 -• 事實與觀點分離:明確區分客觀事實報導與分析師主觀判斷 -• 來源透明化:註明每則重要新聞的原始出處 -• 避免過度解讀:承認信息不完整時的不確定性 -• 量化影響評估:盡可能提供對財務指標的數值影響估算 -• 多角度驗證:對重大新聞交叉比對多個來源 -• 時效性敏感:優先報導最新、最相關的新聞事件 -• 識別噪音:區分真正重要的新聞與市場雜音 - -請以華爾街日報或金融時報的專業標準,提供深度且客觀的新聞分析。""" - + """ 請務必在報告結尾附加一個 Markdown 表格,以整理報告中的要點,使其井然有序且易於閱讀。""", +請以實用為導向,提供清晰易懂的新聞分析。""" + + """ 請務必在報告結尾附加一個 Markdown 表格,以整理報告中的要點。""", ) prompt = ChatPromptTemplate.from_messages( diff --git a/tradingagents/agents/utils/technical_indicators_tools.py b/tradingagents/agents/utils/technical_indicators_tools.py index 695eedc7..a6496187 100644 --- a/tradingagents/agents/utils/technical_indicators_tools.py +++ b/tradingagents/agents/utils/technical_indicators_tools.py @@ -23,22 +23,35 @@ def get_indicators( # 規範化指標名稱以匹配供應商的預期格式 indicator_lower = indicator.lower().strip() - # 常見指標名稱映射 - mapping = { - "sma50": "close_50_sma", - "sma200": "close_200_sma", - "ema10": "close_10_ema", - "bbands": "boll", - "bollinger": "boll", - "macd_signal": "macds", - "macd_hist": "macdh", - } - - # 如果在映射中,使用映射名稱 - if indicator_lower in mapping: - normalized_indicator = mapping[indicator_lower] - # 如果已經是正確的格式(例如 rsi, macd, atr),則保持原樣(轉小寫) + # 處理常見的變體 + if "50" in indicator_lower and ("ma" in indicator_lower or "avg" in indicator_lower): + normalized_indicator = "close_50_sma" + elif "200" in indicator_lower and ("ma" in indicator_lower or "avg" in indicator_lower): + normalized_indicator = "close_200_sma" + elif "10" in indicator_lower and "ema" in indicator_lower: + normalized_indicator = "close_10_ema" else: - normalized_indicator = indicator_lower + # 常見指標名稱映射 + mapping = { + "sma50": "close_50_sma", + "sma200": "close_200_sma", + "ema10": "close_10_ema", + "bbands": "boll", + "bollinger": "boll", + "bollinger bands": "boll", + "macd_signal": "macds", + "macd_hist": "macdh", + "50-day ma": "close_50_sma", + "200-day ma": "close_200_sma", + "50 day ma": "close_50_sma", + "200 day ma": "close_200_sma", + } + + # 如果在映射中,使用映射名稱 + if indicator_lower in mapping: + normalized_indicator = mapping[indicator_lower] + # 如果已經是正確的格式(例如 rsi, macd, atr),則保持原樣(轉小寫) + else: + normalized_indicator = indicator_lower return route_to_vendor("get_indicators", symbol, normalized_indicator, curr_date, look_back_days)