$npx -y skills add agiprolabs/claude-trading-skills --skill sentiment-analysisMarket sentiment extraction from social media, news, and on-chain data including mention velocity, fear and greed indices, and influencer tracking
| 1 | # Sentiment Analysis |
| 2 | |
| 3 | Extract and quantify market sentiment from social media, news feeds, and on-chain |
| 4 | data to identify crowd positioning and potential contrarian opportunities. |
| 5 | |
| 6 | ## When to Use This Skill |
| 7 | |
| 8 | - Gauge crowd sentiment before entering or exiting a position |
| 9 | - Detect euphoria/panic extremes that precede reversals |
| 10 | - Monitor social mention velocity for early trend detection |
| 11 | - Track influencer activity around specific tokens |
| 12 | - Build composite sentiment scores for systematic strategies |
| 13 | |
| 14 | ## Core Concepts |
| 15 | |
| 16 | ### Sentiment Data Sources |
| 17 | |
| 18 | | Source | Data Type | Access | |
| 19 | |--------|-----------|--------| |
| 20 | | Twitter/X | Post text, engagement, follower counts | API (paid tiers) | |
| 21 | | Reddit | Subreddit posts, comments, upvotes | Reddit API | |
| 22 | | Telegram | Channel messages, member counts | Bot API or scraping | |
| 23 | | Discord | Server activity, message volume | Bot integration | |
| 24 | | News | Headlines, article text | NewsAPI, RSS feeds | |
| 25 | | CoinGecko | Community stats, developer activity | Free API | |
| 26 | | Alternative.me | Fear & Greed Index | Free API | |
| 27 | | On-chain | Funding rates, exchange flows | Exchange APIs | |
| 28 | |
| 29 | See `references/data_sources.md` for complete API details, rate limits, and access |
| 30 | patterns for each source. |
| 31 | |
| 32 | ### Sentiment Metrics |
| 33 | |
| 34 | **Mention Velocity** — Rate of token mentions over time: |
| 35 | |
| 36 | ```python |
| 37 | mention_velocity = mentions_last_hour / baseline_hourly_mentions |
| 38 | # > 3.0 = trending, > 10.0 = viral |
| 39 | ``` |
| 40 | |
| 41 | **Sentiment Polarity** — Positive vs negative tone: |
| 42 | |
| 43 | ```python |
| 44 | polarity = (positive_count - negative_count) / total_count |
| 45 | # Range: -1.0 (all negative) to +1.0 (all positive) |
| 46 | ``` |
| 47 | |
| 48 | **Fear & Greed Index** — Composite market mood (0-100): |
| 49 | |
| 50 | | Range | Label | Typical Signal | |
| 51 | |-------|-------|----------------| |
| 52 | | 0-24 | Extreme Fear | Potential accumulation zone | |
| 53 | | 25-44 | Fear | Below-average sentiment | |
| 54 | | 45-55 | Neutral | No strong directional bias | |
| 55 | | 56-74 | Greed | Above-average sentiment | |
| 56 | | 75-100 | Extreme Greed | Potential distribution zone | |
| 57 | |
| 58 | **Social Volume** — Total mentions across platforms: |
| 59 | |
| 60 | ```python |
| 61 | social_volume_z = (current_volume - mean_30d) / std_30d |
| 62 | # z > 2.0 suggests unusual activity |
| 63 | ``` |
| 64 | |
| 65 | ### On-Chain Sentiment Proxies |
| 66 | |
| 67 | On-chain data reveals what participants are doing, not just saying: |
| 68 | |
| 69 | **Funding Rates** — Perpetual futures cost of carry: |
| 70 | |
| 71 | ```python |
| 72 | # Positive funding = longs pay shorts (bullish crowding) |
| 73 | # Negative funding = shorts pay longs (bearish crowding) |
| 74 | funding_sentiment = -1.0 * normalize(funding_rate, -0.1, 0.1) |
| 75 | # Inverted: high positive funding is contrarian bearish |
| 76 | ``` |
| 77 | |
| 78 | **Long/Short Ratio** — Proportion of leveraged positions: |
| 79 | |
| 80 | ```python |
| 81 | ls_ratio = long_accounts / short_accounts |
| 82 | # > 2.0 = crowded long, < 0.5 = crowded short |
| 83 | ls_sentiment = -1.0 * normalize(ls_ratio, 0.5, 2.0) |
| 84 | ``` |
| 85 | |
| 86 | **Exchange Flows** — Net deposits/withdrawals: |
| 87 | |
| 88 | ```python |
| 89 | net_flow = exchange_inflows - exchange_outflows |
| 90 | # Positive net flow (deposits) = bearish (selling pressure) |
| 91 | # Negative net flow (withdrawals) = bullish (accumulation) |
| 92 | flow_sentiment = -1.0 * normalize(net_flow, -threshold, threshold) |
| 93 | ``` |
| 94 | |
| 95 | ### Keyword-Based Sentiment Scoring |
| 96 | |
| 97 | A simple, LLM-free approach using curated word lists: |
| 98 | |
| 99 | ```python |
| 100 | BULLISH_KEYWORDS = { |
| 101 | "moon": 2, "bullish": 2, "pump": 1, "breakout": 2, |
| 102 | "buy": 1, "long": 1, "accumulate": 2, "undervalued": 2, |
| 103 | "gem": 1, "rocket": 1, "ath": 1, "rally": 2, |
| 104 | } |
| 105 | BEARISH_KEYWORDS = { |
| 106 | "dump": 2, "bearish": 2, "crash": 2, "scam": 3, |
| 107 | "rug": 3, "sell": 1, "short": 1, "overvalued": 2, |
| 108 | "dead": 2, "rekt": 1, "ponzi": 3, "exit": 1, |
| 109 | } |
| 110 | |
| 111 | def score_text(text: str) -> float: |
| 112 | """Score text from -1.0 (bearish) to +1.0 (bullish).""" |
| 113 | words = text.lower().split() |
| 114 | bull_score = sum(BULLISH_KEYWORDS.get(w, 0) for w in words) |
| 115 | bear_score = sum(BEARISH_KEYWORDS.get(w, 0) for w in words) |
| 116 | total = bull_score + bear_score |
| 117 | if total == 0: |
| 118 | return 0.0 |
| 119 | return (bull_score - bear_score) / total |
| 120 | ``` |
| 121 | |
| 122 | See `references/scoring_methods.md` for the full methodology, temporal decay |
| 123 | weighting, and composite score construction. |
| 124 | |
| 125 | ### Composite Sentiment Score |
| 126 | |
| 127 | Combine multiple signals into a single score: |
| 128 | |
| 129 | ```python |
| 130 | def composite_sentiment( |
| 131 | social_polarity: float, # -1.0 to +1.0 |
| 132 | mention_velocity: float, # 0 to inf |
| 133 | fear_greed: int, # 0 to 100 |
| 134 | funding_rate: float, # -0.1 to +0.1 |
| 135 | weights: dict | None = None, |
| 136 | ) -> float: |
| 137 | """Compute weighted composite sentiment score (-100 to +100). |
| 138 | |
| 139 | Args: |
| 140 | social_polarity: Average polarity of social mentions. |
| 141 | mention_velocity: Current velocity vs baseline. |
| 142 | fear_greed: Fear & Greed index reading. |
| 143 | funding_rate: Current perpetual funding rate. |
| 144 | weights: Optional custom weights. |
| 145 | |
| 146 | Returns: |
| 147 | Composite score from -100 (extreme fear) to +100 (extreme greed). |
| 148 | """ |
| 149 | w = weights or { |