sentiment-analysis

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sentiment Analysis

情绪分析

Extract and quantify market sentiment from social media, news feeds, and on-chain data to identify crowd positioning and potential contrarian opportunities.
从社交媒体、新闻源和链上数据中提取并量化市场情绪,以识别群体持仓和潜在的逆向投资机会。

When to Use This Skill

何时使用此技能

  • Gauge crowd sentiment before entering or exiting a position
  • Detect euphoria/panic extremes that precede reversals
  • Monitor social mention velocity for early trend detection
  • Track influencer activity around specific tokens
  • Build composite sentiment scores for systematic strategies
  • 在进入或退出仓位前衡量群体情绪
  • 检测反转前出现的狂热/恐慌极端
  • 监控社交提及速度以发现早期趋势
  • 追踪特定代币周围的影响者活动
  • 为系统性策略构建综合情绪得分

Core Concepts

核心概念

Sentiment Data Sources

情绪数据源

SourceData TypeAccess
Twitter/XPost text, engagement, follower countsAPI (paid tiers)
RedditSubreddit posts, comments, upvotesReddit API
TelegramChannel messages, member countsBot API or scraping
DiscordServer activity, message volumeBot integration
NewsHeadlines, article textNewsAPI, RSS feeds
CoinGeckoCommunity stats, developer activityFree API
Alternative.meFear & Greed IndexFree API
On-chainFunding rates, exchange flowsExchange APIs
See
references/data_sources.md
for complete API details, rate limits, and access patterns for each source.
数据源数据类型访问方式
Twitter/X帖子文本、互动、关注者数量API(付费层级)
Reddit子版块帖子、评论、点赞Reddit API
Telegram频道消息、成员数量Bot API 或爬取
Discord服务器活动、消息量Bot集成
News头条、文章文本NewsAPI、RSS源
CoinGecko社区统计、开发者活动免费API
Alternative.me恐惧与贪婪指数免费API
链上资金费率、交易所流量交易所API
有关每个数据源的完整API详情、速率限制和访问模式,请参阅
references/data_sources.md
。

Sentiment Metrics

情绪指标

Mention Velocity — Rate of token mentions over time:
python
mention_velocity = mentions_last_hour / baseline_hourly_mentions
提及速度 — 代币随时间被提及的速率:
python
mention_velocity = mentions_last_hour / baseline_hourly_mentions

> 3.0 = trending, > 10.0 = viral

> 3.0 = trending, > 10.0 = viral


**Sentiment Polarity** — Positive vs negative tone:

```python
polarity = (positive_count - negative_count) / total_count

**情绪极性** — 正面与负面语气:

```python
polarity = (positive_count - negative_count) / total_count

Range: -1.0 (all negative) to +1.0 (all positive)

Range: -1.0 (all negative) to +1.0 (all positive)


**Fear & Greed Index** — Composite market mood (0-100):

| Range | Label | Typical Signal |
|-------|-------|----------------|
| 0-24 | Extreme Fear | Potential accumulation zone |
| 25-44 | Fear | Below-average sentiment |
| 45-55 | Neutral | No strong directional bias |
| 56-74 | Greed | Above-average sentiment |
| 75-100 | Extreme Greed | Potential distribution zone |

**Social Volume** — Total mentions across platforms:

```python
social_volume_z = (current_volume - mean_30d) / std_30d

**恐惧与贪婪指数** — 综合市场情绪(0-100):

| 范围 | 标签 | 典型信号 |
|-------|-------|----------------|
| 0-24 | 极度恐惧 | 潜在积累区 |
| 25-44 | 恐惧 | 低于平均的情绪 |
| 45-55 | 中性 | 没有强烈的方向性偏差 |
| 56-74 | 贪婪 | 高于平均的情绪 |
| 75-100 | 极度贪婪 | 潜在分配区 |

**社交量** — 各平台的总提及次数:

```python
social_volume_z = (current_volume - mean_30d) / std_30d

z > 2.0 suggests unusual activity

z > 2.0 suggests unusual activity

undefined
undefined

On-Chain Sentiment Proxies

链上情绪代理指标

On-chain data reveals what participants are doing, not just saying:
Funding Rates — Perpetual futures cost of carry:
python
undefined
链上数据揭示参与者的实际行为,而不仅是言论:
资金费率 — 永续合约的持仓成本:
python
undefined

Positive funding = longs pay shorts (bullish crowding)

Positive funding = longs pay shorts (bullish crowding)

Negative funding = shorts pay longs (bearish crowding)

Negative funding = shorts pay longs (bearish crowding)

funding_sentiment = -1.0 * normalize(funding_rate, -0.1, 0.1)
funding_sentiment = -1.0 * normalize(funding_rate, -0.1, 0.1)

Inverted: high positive funding is contrarian bearish

Inverted: high positive funding is contrarian bearish


**Long/Short Ratio** — Proportion of leveraged positions:

```python
ls_ratio = long_accounts / short_accounts

**多空比** — 杠杆仓位比例:

```python
ls_ratio = long_accounts / short_accounts

> 2.0 = crowded long, < 0.5 = crowded short

> 2.0 = crowded long, < 0.5 = crowded short

ls_sentiment = -1.0 * normalize(ls_ratio, 0.5, 2.0)

**Exchange Flows** — Net deposits/withdrawals:

```python
net_flow = exchange_inflows - exchange_outflows
ls_sentiment = -1.0 * normalize(ls_ratio, 0.5, 2.0)

**交易所流量** — 净存入/提取:

```python
net_flow = exchange_inflows - exchange_outflows

Positive net flow (deposits) = bearish (selling pressure)

Positive net flow (deposits) = bearish (selling pressure)

Negative net flow (withdrawals) = bullish (accumulation)

Negative net flow (withdrawals) = bullish (accumulation)

flow_sentiment = -1.0 * normalize(net_flow, -threshold, threshold)
undefined
flow_sentiment = -1.0 * normalize(net_flow, -threshold, threshold)
undefined

Keyword-Based Sentiment Scoring

基于关键词的情绪评分

A simple, LLM-free approach using curated word lists:
python
BULLISH_KEYWORDS = {
    "moon": 2, "bullish": 2, "pump": 1, "breakout": 2,
    "buy": 1, "long": 1, "accumulate": 2, "undervalued": 2,
    "gem": 1, "rocket": 1, "ath": 1, "rally": 2,
}
BEARISH_KEYWORDS = {
    "dump": 2, "bearish": 2, "crash": 2, "scam": 3,
    "rug": 3, "sell": 1, "short": 1, "overvalued": 2,
    "dead": 2, "rekt": 1, "ponzi": 3, "exit": 1,
}

def score_text(text: str) -> float:
    """Score text from -1.0 (bearish) to +1.0 (bullish)."""
    words = text.lower().split()
    bull_score = sum(BULLISH_KEYWORDS.get(w, 0) for w in words)
    bear_score = sum(BEARISH_KEYWORDS.get(w, 0) for w in words)
    total = bull_score + bear_score
    if total == 0:
        return 0.0
    return (bull_score - bear_score) / total
See
references/scoring_methods.md
for the full methodology, temporal decay weighting, and composite score construction.
一种简单、无需LLM的方法,使用精心策划的单词列表:
python
BULLISH_KEYWORDS = {
    "moon": 2, "bullish": 2, "pump": 1, "breakout": 2,
    "buy": 1, "long": 1, "accumulate": 2, "undervalued": 2,
    "gem": 1, "rocket": 1, "ath": 1, "rally": 2,
}
BEARISH_KEYWORDS = {
    "dump": 2, "bearish": 2, "crash": 2, "scam": 3,
    "rug": 3, "sell": 1, "short": 1, "overvalued": 2,
    "dead": 2, "rekt": 1, "ponzi": 3, "exit": 1,
}

def score_text(text: str) -> float:
    """Score text from -1.0 (bearish) to +1.0 (bullish)."""
    words = text.lower().split()
    bull_score = sum(BULLISH_KEYWORDS.get(w, 0) for w in words)
    bear_score = sum(BEARISH_KEYWORDS.get(w, 0) for w in words)
    total = bull_score + bear_score
    if total == 0:
        return 0.0
    return (bull_score - bear_score) / total
有关完整方法、时间衰减加权和综合得分构建,请参阅
references/scoring_methods.md
。

Composite Sentiment Score

综合情绪得分

Combine multiple signals into a single score:
python
def composite_sentiment(
    social_polarity: float,    # -1.0 to +1.0
    mention_velocity: float,   # 0 to inf
    fear_greed: int,           # 0 to 100
    funding_rate: float,       # -0.1 to +0.1
    weights: dict | None = None,
) -> float:
    """Compute weighted composite sentiment score (-100 to +100).

    Args:
        social_polarity: Average polarity of social mentions.
        mention_velocity: Current velocity vs baseline.
        fear_greed: Fear & Greed index reading.
        funding_rate: Current perpetual funding rate.
        weights: Optional custom weights.

    Returns:
        Composite score from -100 (extreme fear) to +100 (extreme greed).
    """
    w = weights or {
        "social": 0.30,
        "velocity": 0.15,
        "fear_greed": 0.30,
        "funding": 0.25,
    }
    # Normalize each component to -1.0 to +1.0
    s_social = social_polarity
    s_velocity = min(mention_velocity / 10.0, 1.0)  # Cap at 10x
    s_fg = (fear_greed - 50) / 50.0  # 0-100 -> -1 to +1
    s_funding = -10.0 * funding_rate  # Contrarian: high funding = bearish
    s_funding = max(-1.0, min(1.0, s_funding))

    raw = (
        w["social"] * s_social
        + w["velocity"] * s_velocity
        + w["fear_greed"] * s_fg
        + w["funding"] * s_funding
    )
    return round(raw * 100, 1)
将多个信号组合成单一得分:
python
def composite_sentiment(
    social_polarity: float,    # -1.0 to +1.0
    mention_velocity: float,   # 0 to inf
    fear_greed: int,           # 0 to 100
    funding_rate: float,       # -0.1 to +0.1
    weights: dict | None = None,
) -> float:
    """Compute weighted composite sentiment score (-100 to +100).

    Args:
        social_polarity: Average polarity of social mentions.
        mention_velocity: Current velocity vs baseline.
        fear_greed: Fear & Greed index reading.
        funding_rate: Current perpetual funding rate.
        weights: Optional custom weights.

    Returns:
        Composite score from -100 (extreme fear) to +100 (extreme greed).
    """
    w = weights or {
        "social": 0.30,
        "velocity": 0.15,
        "fear_greed": 0.30,
        "funding": 0.25,
    }
    # Normalize each component to -1.0 to +1.0
    s_social = social_polarity
    s_velocity = min(mention_velocity / 10.0, 1.0)  # Cap at 10x
    s_fg = (fear_greed - 50) / 50.0  # 0-100 -> -1 to +1
    s_funding = -10.0 * funding_rate  # Contrarian: high funding = bearish
    s_funding = max(-1.0, min(1.0, s_funding))

    raw = (
        w["social"] * s_social
        + w["velocity"] * s_velocity
        + w["fear_greed"] * s_fg
        + w["funding"] * s_funding
    )
    return round(raw * 100, 1)

Contrarian Signals

逆向信号

Extreme sentiment readings often precede reversals:
ConditionInterpretation
Composite < -70Extreme fear — historically a buying zone
Composite > +70Extreme greed — historically a selling zone
Velocity > 10x + polarity > 0.6Euphoric spike — fade potential
Velocity > 10x + polarity < -0.6Panic spike — bounce potential
Funding > 0.05% + LS ratio > 2.0Crowded long — liquidation risk
Funding < -0.05% + LS ratio < 0.5Crowded short — squeeze risk
Key principle: Sentiment is most useful at extremes. Neutral readings (composite between -30 and +30) have low predictive value.
极端的情绪读数往往先于反转:
条件解读
综合得分 < -70极度恐惧 — 历史上是买入区域
综合得分 > +70极度贪婪 — 历史上是卖出区域
速度 > 10倍 + 极性 > 0.6狂喜飙升 — 潜在回落
速度 > 10倍 + 极性 < -0.6恐慌飙升 — 潜在反弹
资金费率 > 0.05% + 多空比 > 2.0拥挤的多头 — 清算风险
资金费率 < -0.05% + 多空比 < 0.5拥挤的空头 — 挤压风险
关键原则:情绪在极端情况下最有用。中性读数(综合得分在-30到+30之间)的预测价值较低。

Influencer Tracking

影响者追踪

Monitor high-follower accounts for early signal detection:
python
def influencer_signal(
    posts: list[dict],
    min_followers: int = 50_000,
    lookback_hours: int = 24,
) -> dict:
    """Detect influencer activity around a token.

    Args:
        posts: List of posts with 'followers', 'timestamp', 'sentiment'.
        min_followers: Minimum follower count to qualify as influencer.
        lookback_hours: Time window in hours.

    Returns:
        Dict with influencer_count, avg_sentiment, total_reach.
    """
    cutoff = time.time() - (lookback_hours * 3600)
    relevant = [
        p for p in posts
        if p["followers"] >= min_followers and p["timestamp"] >= cutoff
    ]
    if not relevant:
        return {"influencer_count": 0, "avg_sentiment": 0.0, "total_reach": 0}
    return {
        "influencer_count": len(relevant),
        "avg_sentiment": sum(p["sentiment"] for p in relevant) / len(relevant),
        "total_reach": sum(p["followers"] for p in relevant),
    }
监控高关注者账户以早期发现信号:
python
def influencer_signal(
    posts: list[dict],
    min_followers: int = 50_000,
    lookback_hours: int = 24,
) -> dict:
    """Detect influencer activity around a token.

    Args:
        posts: List of posts with 'followers', 'timestamp', 'sentiment'.
        min_followers: Minimum follower count to qualify as influencer.
        lookback_hours: Time window in hours.

    Returns:
        Dict with influencer_count, avg_sentiment, total_reach.
    """
    cutoff = time.time() - (lookback_hours * 3600)
    relevant = [
        p for p in posts
        if p["followers"] >= min_followers and p["timestamp"] >= cutoff
    ]
    if not relevant:
        return {"influencer_count": 0, "avg_sentiment": 0.0, "total_reach": 0}
    return {
        "influencer_count": len(relevant),
        "avg_sentiment": sum(p["sentiment"] for p in relevant) / len(relevant),
        "total_reach": sum(p["followers"] for p in relevant),
    }

Integration With Other Skills

与其他技能的集成

SkillIntegration Point
position-sizing
Reduce size in extreme greed, increase in extreme fear
risk-management
Tighten stops when sentiment diverges from price
regime-detection
Sentiment confirms or contradicts regime classification
feature-engineering
Sentiment metrics as ML features
signal-classification
Sentiment as input to signal scoring models
whale-tracking
Combine whale activity with social sentiment
token-holder-analysis
Holder growth/decline as sentiment proxy
技能集成点
position-sizing
(仓位管理)
在极度贪婪时减少仓位,在极度恐惧时增加仓位
risk-management
(风险管理)
当情绪与价格背离时收紧止损
regime-detection
(体制检测)
情绪确认或反驳体制分类
feature-engineering
(特征工程)
情绪指标作为机器学习特征
signal-classification
(信号分类)
情绪作为信号评分模型的输入
whale-tracking
(鲸鱼追踪)
将鲸鱼活动与社交情绪结合
token-holder-analysis
(代币持有者分析)
持有者增长/减少作为情绪代理

Practical Workflow

实际工作流程

1. Fetch fear/greed index          → Market-wide mood
2. Pull social data for token      → Token-specific sentiment
3. Score text with keyword method  → Polarity scores
4. Compute mention velocity        → Trending detection
5. Check on-chain proxies          → Funding, flows
6. Calculate composite score       → Single decision input
7. Flag contrarian signals         → Extreme readings
8. Integrate with position sizing  → Adjust allocation
1. Fetch fear/greed index          → Market-wide mood
2. Pull social data for token      → Token-specific sentiment
3. Score text with keyword method  → Polarity scores
4. Compute mention velocity        → Trending detection
5. Check on-chain proxies          → Funding, flows
6. Calculate composite score       → Single decision input
7. Flag contrarian signals         → Extreme readings
8. Integrate with position sizing  → Adjust allocation

Limitations and Warnings

局限性与警告

  • Sentiment is noisy. Individual readings are unreliable — use trends and extremes.
  • Social data is gameable. Bot activity can inflate mention counts.
  • Keyword scoring is crude. It misses sarcasm, context, and nuance.
  • Lag exists. By the time sentiment is measurable, price may have moved.
  • Not financial advice. Sentiment data is for informational and analytical purposes only.
  • API access varies. Twitter/X API pricing has changed frequently. Budget accordingly.
  • Survivorship bias. Tokens that go to zero stop being discussed — absence of mentions is also a signal.
  • 情绪是嘈杂的。 单独的读数不可靠 — 应使用趋势和极端值。
  • 社交数据可被操纵。 机器人活动可能夸大提及数量。
  • 关键词评分是粗略的。 它无法识别讽刺、上下文和细微差别。
  • 存在滞后。 当情绪可测量时,价格可能已经变动。
  • 不是财务建议。 情绪数据仅供参考和分析之用。
  • API访问各不相同。 Twitter/X API定价频繁变化。请相应预算。
  • 幸存者偏差。 归零的代币不再被讨论 — 提及的缺失也是一种信号。

Files

文件

References

参考

  • references/data_sources.md
    — API details, rate limits, and access patterns for all sentiment data sources
  • references/scoring_methods.md
    — Keyword lists, composite scoring methodology, temporal decay, contrarian logic
  • references/data_sources.md
    — 所有情绪数据源的API详情、速率限制和访问模式
  • references/scoring_methods.md
    — 关键词列表、综合评分方法、时间衰减、逆向逻辑

Scripts

脚本

  • scripts/sentiment_scanner.py
    — Fetches live sentiment data from free APIs, computes composite scores, flags contrarian signals
  • scripts/keyword_sentiment.py
    — Standalone keyword-based text sentiment analyzer with synthetic demo data
  • scripts/sentiment_scanner.py
    — 从免费API获取实时情绪数据,计算综合得分,标记逆向信号
  • scripts/keyword_sentiment.py
    — 独立的基于关键词的文本情绪分析器,带有合成演示数据