← 返回
未分类

Sentiment Analyzer

Analyze market sentiment from news articles, social media posts, and financial headlines. Extract bullish/bearish signals, keyword trends, and sentiment scor...
从新闻文章、社交媒体帖子和财经标题中分析市场情绪,提取看涨/看跌信号、关键词趋势和情绪评分。
zhaocaixia888 zhaocaixia888 来源
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 124
下载
💾 0
安装
1
版本
#latest

概述

Sentiment Analyzer — 市场情绪分析

Extract and quantify market sentiment from financial news, social media, and headlines. Supports Chinese and English with domain-specific keyword dictionaries.

Quick Start

Core Sentiment Analysis

# Chinese/English sentiment keywords
BULLISH = {
    "利好", "大涨", "突破", "反弹", "看多", "做多", "抄底", "放量上涨",
    "金叉", "上攻", "拉升", "启动", "触底反弹", "企稳回升",
    "增持", "回购", "政策支持", "降息", "放水", "宽松",
    "rally", "breakout", "bullish", "surge", "upgrade", "outperform",
    "beat earnings", "guidance up", "buyback", "dividend increase"
}

BEARISH = {
    "利空", "大跌", "跌破", "回调", "看空", "做空", "逃顶", "放量下跌",
    "死叉", "下探", "杀跌", "出货", "暴雷", "崩盘", "阴跌",
    "减持", "解禁", "加息", "收紧", "紧缩", "贸易战",
    "crash", "plunge", "bearish", "downgrade", "sell-off", "underperform",
    "miss earnings", "guidance down", "layoff", "investigation"
}

def analyze_text(text):
    """Analyze sentiment of a single text."""
    bullish = sum(1 for kw in BULLISH if kw in text)
    bearish = sum(1 for kw in BEARISH if kw in text)
    total = bullish + bearish
    
    if total == 0:
        return {"sentiment": "neutral", "score": 0.0, "bullish": 0, "bearish": 0}
    
    score = (bullish - bearish) / total
    if score > 0.2: sent = "bullish"
    elif score < -0.2: sent = "bearish"
    else: sent = "neutral"
    
    return {"sentiment": sent, "score": round(score, 2), "bullish": bullish, "bearish": bearish}

Batch Analysis

def batch_analyze(headlines):
    """Analyze a list of headlines."""
    results = [analyze_text(h) for h in headlines]
    bullish = sum(1 for r in results if r["sentiment"] == "bullish")
    bearish = sum(1 for r in results if r["sentiment"] == "bearish")
    neutral = sum(1 for r in results if r["sentiment"] == "neutral")
    avg = sum(r["score"] for r in results) / len(results) if results else 0
    
    return {
        "total": len(headlines),
        "bullish": bullish,
        "bearish": bearish,
        "neutral": neutral,
        "bullish_pct": round(bullish / len(headlines) * 100, 1) if headlines else 0,
        "avg_score": round(avg, 2),
        "overall": "bullish" if bullish > bearish else ("bearish" if bearish > bullish else "mixed")
    }

Trending Keywords

from collections import Counter
import re

def extract_keywords(headlines, top_n=10):
    """Extract most frequent market keywords from headlines."""
    all_words = []
    for h in headlines:
        words = re.findall(r'[\w\u4e00-\u9fff]+', h)
        all_words.extend(w for w in words if len(w) > 1)
    counter = Counter(all_words)
    return counter.most_common(top_n)

Data Sources

# Sina Finance headlines
curl -s "https://finance.sina.com.cn/" | grep -oP '(?<=<a[^>]*>)[^<]+' | head -20

# East Money news
curl -s "https://quote.eastmoney.com/" | grep -oP '[\u4e00-\u9fff]{4,}' | head -30

# Weibo trending (public)
curl -s "https://weibo.com/ajax/side/hotSearch"

Format Output

Daily Sentiment Report

🔍 市场情绪快报 (2026-05-22)

📰 新闻情绪分析 (共15条)
• 看多: 6条 (40.0%) 🟢
• 看空: 4条 (26.7%) 🔴
• 中性: 5条 (33.3%) ⚪
• 平均得分: +0.15 (偏多)

🔥 热门关键词
利好(3) 突破(2) 政策支持(2) 反弹(2)
利空(2) 回调(2) 加息(1) 放量(1)

📊 品种情绪分时
• 焦炭 🟢 +0.45  螺纹 🟢 +0.30
• 沪铜 🟡 +0.10  原油 🟡 +0.05
• 纯碱 🔴 -0.35  玻璃 🔴 -0.28

⚠️ 情绪分析仅供参考,不构成交易建议

News Item Analysis

📰 [标题] 央行降准0.5个百分点 释放长期资金约1万亿
📊 情绪: bullish 🟢 (得分: +0.67)
🔑 关键词: 降准(利好), 释放资金(利好), 宽松
💡 影响: 利好股市,利多银行/地产板块

Trend Tracking

📈 品种情绪趋势 (近7天)
品种    周一  周二  周三  周四  周五  方向
焦炭    +0.2  +0.3  +0.1  +0.4  +0.5  ↗️
螺纹    -0.1  -0.3  -0.2   0.0  +0.3  ↗️
纯碱    -0.4  -0.5  -0.3  -0.6  -0.4  ↘️

Use Cases

  • Pre-market check: Scan overnight news sentiment before trading
  • Position monitoring: Track sentiment changes for held positions
  • Earnings season: Analyze sentiment around earnings reports
  • Contrarian signals: Extreme sentiment (90%+ one direction) often signals reversal
  • Sector rotation: Compare sentiment across sectors to identify rotation

Notes

  • This is keyword-based sentiment analysis, NOT deep NLP
  • Works better with longer texts (headlines + first paragraph)
  • Chinese sentiment keywords need regular maintenance (new slang emerges)
  • Combine with volume/price data for confirmation signals
  • For production, consider finBERT or other pre-trained financial NLP models

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-06-04 14:07

安全检测

腾讯云安全 (Keen)

队列中

腾讯云安全 (Sanbu)

队列中

🔗 相关推荐

professional

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 197 📥 63,835
professional

All-Market Financial Data Hub

financial-ai-analyst
基于东方财富数据库,支持自然语言查询金融数据,覆盖A股、港股、美股、基金、债券等资产,提供实时行情、公司信息、估值、财务报表等,适用于投资研究、交易复盘、市场监控、行业分析、信用研究、财报审计、资产配置等场景,满足机构与个人需求。返回结果为
★ 132 📥 42,725
professional

Stock Market Pro

kys42
Yahoo Finance (yfinance) 驱动的股票分析技能:行情报价、基本面、ASCII 趋势图、高分辨率图表(RSI/MACD/BB/VWAP/ATR),以及可选的网络...
★ 165 📥 40,349