关于 sentiment-analysis
sentiment-analysis 是一项从社交媒体、新闻和链上信号衡量市场情绪的技能。它介绍用于跟踪趋势、群体仓位和情绪极端值的指标与评分方法。
主要功能
- 01社交与新闻情绪指标
- 02提及速度跟踪
- 03链上情绪代理指标
- 04综合情绪评分
- 05逆向信号检测
- 06影响者活动监测
适用场景
- 01调整仓位前检查群体情绪
- 02发现代币提及量异常激增
- 03在系统化策略中整合情绪信号
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ agiprolabs/ claude-trading-skills --skill sentiment-analysis安装后在 Claude Code 中输入/sentiment-analysis确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/data_sources.mdscoring_methods.mdscripts/keyword_sentiment.pysentiment_scanner.py详细介绍
情绪分析
从社交媒体、新闻源和链上数据中提取并量化市场情绪,以识别群体仓位倾向和潜在的逆向交易机会。
何时使用此技能
- 在建立或退出仓位前评估群体情绪
- 检测可能预示反转的极度兴奋或恐慌情绪
- 监控社交提及速度,以便及早发现趋势
- 追踪特定代币相关的意见领袖活动
- 为系统化策略构建综合情绪评分
核心概念
情绪数据来源
| 来源 | 数据类型 | 访问方式 |
|---|---|---|
| Twitter/X | 帖子文本、互动数据、关注者数量 | API(付费层级) |
| Subreddit 帖子、评论、点赞数 | Reddit API | |
| Telegram | 频道消息、成员数量 | Bot API 或抓取 |
| Discord | 服务器活动、消息量 | Bot 集成 |
| 新闻 | 标题、文章文本 | NewsAPI、RSS 源 |
| CoinGecko | 社区统计数据、开发者活动 | 免费 API |
| Alternative.me | 恐惧与贪婪指数 | 免费 API |
| 链上 | 资金费率、交易所资金流 | 交易所 API |
有关各来源的完整 API 详情、速率限制和访问模式,请参阅 references/data_sources.md。
情绪指标
提及速度 — 代币提及量随时间的变化速率:
mention_velocity = mentions_last_hour / baseline_hourly_mentions
# > 3.0 = trending, > 10.0 = viral
情绪极性 — 正面与负面语气:
polarity = (positive_count - negative_count) / total_count
# Range: -1.0 (all negative) to +1.0 (all positive)
恐惧与贪婪指数 — 综合市场情绪(0-100):
| 范围 | 标签 | 典型信号 |
|---|---|---|
| 0-24 | 极度恐惧 | 潜在的累积区域 |
| 25-44 | 恐惧 | 低于平均水平的情绪 |
| 45-55 | 中性 | 没有明显的方向性倾向 |
| 56-74 | 贪婪 | 高于平均水平的情绪 |
| 75-100 | 极度贪婪 | 潜在的派发区域 |
社交热度 — 各平台的提及总量:
social_volume_z = (current_volume - mean_30d) / std_30d
# z > 2.0 suggests unusual activity
链上情绪代理指标
链上数据揭示参与者的实际行为,而不只是他们的言论:
资金费率 — 永续期货的持仓成本:
# Positive funding = longs pay shorts (bullish crowding)
# Negative funding = shorts pay longs (bearish crowding)
funding_sentiment = -1.0 * normalize(funding_rate, -0.1, 0.1)
# Inverted: high positive funding is contrarian bearish
多空比 — 杠杆仓位的比例:
ls_ratio = long_accounts / short_accounts
# > 2.0 = crowded long, < 0.5 = crowded short
ls_sentiment = -1.0 * normalize(ls_ratio, 0.5, 2.0)
交易所资金流 — 净存入量/提取量:
net_flow = exchange_inflows - exchange_outflows
# Positive net flow (deposits) = bearish (selling pressure)
# Negative net flow (withdrawals) = bullish (accumulation)
flow_sentiment = -1.0 * normalize(net_flow, -threshold, threshold)
基于关键词的情绪评分
一种使用精选词表、不依赖 LLM 的简单方法:
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。
综合情绪评分
将多个信号合并为单一评分:
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)
逆向信号
极端情绪读数往往预示着反转:
| 条件 | 解读 |
|---|---|
| Composite < -70 | 极度恐惧——历史上属于买入区域 |
| Composite > +70 | 极度贪婪——历史上属于卖出区域 |
| Velocity > 10x + polarity > 0.6 | 兴奋情绪飙升——可能适合反向交易 |
| Velocity > 10x + polarity < -0.6 | 恐慌情绪飙升——可能出现反弹 |
| Funding > 0.05% + LS ratio > 2.0 | 多头拥挤——有清算风险 |
| Funding < -0.05% + LS ratio < 0.5 | 空头拥挤——有挤仓风险 |
关键原则:情绪指标在极端值时最有用。中性读数(综合评分介于 -30 和 +30 之间)的预测价值较低。
意见领袖追踪
监控粉丝数较多的账号,以便及早发现信号:
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),
}
与其他技能的集成
| 技能 | 集成点 |
|---|---|
position-sizing | 极度贪婪时缩减仓位,极度恐惧时增加仓位 |
risk-management | 情绪与价格背离时收紧止损 |
regime-detection | 情绪用于确认或否定市场状态分类 |
feature-engineering | 将情绪指标作为 ML 特征 |
signal-classification | 将情绪作为信号评分模型的输入 |
whale-tracking | 将巨鲸活动与社交情绪结合 |
token-holder-analysis | 将持有者增长/减少作为情绪代理指标 |
实用工作流
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
局限性和警告
- 情绪信号噪声较大。 单次读数并不可靠——应关注趋势和极端值。
- 社交数据可能被操纵。 机器人活动可能推高提及次数。
- 关键词评分较为粗略。 无法识别讽刺、语境和细微差别。
- 存在滞后。 情绪数据可供衡量时,价格可能已经变动。
- 不构成财务建议。 情绪数据仅供参考和分析。
- API 访问因情况而异。 Twitter/X API 的定价频繁变动,请据此做好预算。
- 存在幸存者偏差。 归零的代币不再被讨论——没有提及也是一种信号。
文件
参考资料
references/data_sources.md— 所有情绪数据源的 API 详情、速率限制和访问方式references/scoring_methods.md— 关键词列表、综合评分方法、时间衰减和反向逻辑
脚本
scripts/sentiment_scanner.py— 从免费 API 获取实时情绪数据、计算综合评分并标记反向信号scripts/keyword_sentiment.py— 独立的关键词文本情绪分析器,附带合成演示数据
评论
支持 Markdown