Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions skills/macro-intelligence/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "macro-intelligence",
"description": "Unified macro intelligence feed — reads 7 sources, classifies events, scores sentiment, generates AI insights, exposes signals via HTTP API",
"version": "1.0.0",
"version": "2.0.0",
"author": {
"name": "victorlee",
"name": "VibeCodeDaddy",
"github": "VibeCodeDaddy69"
},
"license": "MIT",
Expand Down
344 changes: 175 additions & 169 deletions skills/macro-intelligence/SKILL.md

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions skills/macro-intelligence/SKILL_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# macro-intelligence — Skill Summary

## Overview
Macro Intelligence is a unified macro news and sentiment aggregator that polls 7 data sources — NewsNow headlines, Polymarket prediction markets, 6551.io OpenNews (WebSocket + REST fallback), Finnhub market news with stock/ETF quotes (SPY, GLD, SLV), Telegram groups (30+ macro/whale/alpha channels), FRED economic indicators (Fed Funds Rate, CPI, GDP, Unemployment, yield curve), and the Crypto Fear & Greed Index. Each incoming message passes through a 3-layer classification pipeline: first keyword regex (24+ bilingual EN/CN patterns covering Fed rate decisions, CPI, gold, geopolitical events, tariffs, whale alerts, RWA catalysts), then LLM confirmation for ambiguous matches (0.55-0.80 confidence), then LLM discovery for relevant messages that missed all keywords. A macro playbook maps each classified event to direction, magnitude, and urgency. The Token Impact Engine maps each signal to specific crypto tokens with directional impact scores across 23 event types (e.g. `fed_cut_surprise -> BTC +0.85, ETH +0.80`), with client-side fallback for legacy signals. Source diversity logic guarantees minimum 5 signals per source type across 80 returned signals, preventing any single source from flooding the feed. Sender reputation tracks source reliability with 30-day decay and boosts high-rep senders 1.3x. Cross-source dedup uses MD5 hashing within a 4-hour window. The skill exposes 11 HTTP API endpoints for filtered signals, aggregate sentiment, market regime, Polymarket odds, FRED data, price tickers, and reputation leaderboards. No trading logic — downstream skills consume the signals. Dashboard at `http://localhost:3252`.

## Usage
Start with `python3 macro_news.py` — the skill begins polling all configured sources immediately. All sources are optional and degrade gracefully: without API keys, the skill still runs on NewsNow and Fear & Greed. Add Finnhub (`FINNHUB_API_KEY`), FRED (`FRED_API_KEY`), OpenNews (`OPENNEWS_TOKEN`), or Telegram (`TG_API_ID` / `TG_API_HASH`) for richer coverage. LLM classification requires `ANTHROPIC_API_KEY` (uses Claude Haiku). State persists to `state/state.json` every 10 seconds. Prerequisites: onchainos CLI >= 2.1.0, Python >= 3.9.

## Commands
| Command | Description |
|---|---|
| `python3 macro_news.py` | Start the intelligence feed + dashboard |
| `onchainos wallet login` | Authenticate (required for onchainos integration) |

## Triggers
Activates when the user mentions macro intelligence, macro news feed, sentiment aggregator, macro-intelligence, Fed/CPI/macro signals, news classification, real-time macro monitoring for trading, token impact, or source diversity.
31 changes: 31 additions & 0 deletions skills/macro-intelligence/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# macro-intelligence

## Overview

Unified macro intelligence feed that reads 7 sources (NewsNow, Polymarket, OpenNews, Finnhub, Telegram, FRED, Fear & Greed), classifies events with regex + LLM, scores sentiment, and exposes filtered signals via HTTP API for downstream trading skills. Read-only intelligence feed — no trading logic.

Core operations:

- Aggregate financial news from 7 sources with automatic polling
- Classify events into 24+ types with bilingual pattern matching and LLM confirmation
- Map macro signals to specific crypto tokens with directional impact scores
- Expose 11 HTTP API endpoints for filtered signals, sentiment, and regime detection
- Render neon-glass terminal dashboard with heat columns, sparklines, and token impact pills

Tags: `macro` `news` `sentiment` `intelligence` `fred` `polymarket` `dashboard`

## Prerequisites

- Python 3.8+ (stdlib only, no pip dependencies)
- Optional: Finnhub API key (`FINNHUB_API_KEY`), Telegram bot token (`TELEGRAM_BOT_TOKEN`) — sources degrade gracefully
- Optional: `ANTHROPIC_API_KEY` for LLM-powered headline classification

## Quick Start

1. **Start the server**: Run `python3 macro_news.py` from the skill directory. Dashboard opens at `http://localhost:3250` and API at `http://localhost:3250/api/signals`.

2. **Browse signals**: The dashboard shows a live feed of classified macro events with sentiment scores, source attribution, and token impact predictions. All 7 sources poll automatically.

3. **Query the API**: Use endpoints like `/api/signals?type=fed_rate` to filter by event type, `/api/sentiment` for aggregate sentiment, or `/api/regime` for current market regime detection.

4. **Integrate with trading skills**: Downstream skills (like rwa-alpha) can poll the signals API to trigger trades based on macro events.
103 changes: 101 additions & 2 deletions skills/macro-intelligence/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
OPENNEWS_WSS_URL = "wss://ai.6551.io/open/news_wss"
OPENNEWS_API_BASE = "https://ai.6551.io"
OPENNEWS_MIN_SCORE = 40 # Only process articles with AI score >= 40
OPENNEWS_ENGINE_TYPES = ["news"] # "news", "listing", "onchain", "meme", "market", "prediction"
OPENNEWS_POLL_SEC = 120 # REST fallback interval (if WebSocket disconnects)
OPENNEWS_ENGINE_TYPES = ["news", "listing", "onchain", "meme", "market", "prediction"]
OPENNEWS_POLL_SEC = 60 # REST poll interval (WS returns 403 on free tier)
OPENNEWS_MAX_ARTICLES = 1000 # Article buffer size for OpenNews dashboard tab
OPENNEWS_HIGH_SCORE_THRESHOLD = 70
OPENNEWS_SOURCE_STALE = 300 # seconds before source is "stale"
OPENNEWS_SOURCE_DEAD = 1800 # seconds before source is "dead"

# ═══════════════════════════════════════════════════════════════════════
# Finnhub Market News
Expand Down Expand Up @@ -308,6 +312,54 @@
"gdp_weak": {"direction": "bullish", "magnitude": 0.55, "affects": ["rwa", "perps"], "urgency": 0.4},
}

# ═══════════════════════════════════════════════════════════════════════
# TOKEN IMPACT MAP — Maps event_type → which crypto tokens are affected
# Values are (symbol, base_impact) where impact is -1.0 to +1.0
# Positive = bullish for that token, negative = bearish
# Scaled by signal magnitude at runtime
# ═══════════════════════════════════════════════════════════════════════
TOKEN_IMPACT_MAP = {
# ── Fed / Rates (rate cuts = risk-on = crypto up; hikes = risk-off) ──
"fed_cut_surprise": [("BTC", 0.85), ("ETH", 0.80), ("SOL", 0.75), ("ONDO", 0.50), ("LINK", 0.40)],
"fed_cut_expected": [("BTC", 0.50), ("ETH", 0.45), ("SOL", 0.40), ("ONDO", 0.30)],
"fed_hold_hawkish": [("BTC", -0.55), ("ETH", -0.50), ("SOL", -0.60), ("ONDO", -0.35)],
"fed_hike": [("BTC", -0.75), ("ETH", -0.70), ("SOL", -0.80), ("ONDO", -0.50)],
"fed_dovish": [("BTC", 0.55), ("ETH", 0.50), ("SOL", 0.45), ("ONDO", 0.35)],
# ── CPI / Inflation (hot CPI = hawkish expectation; cool = dovish) ──
"cpi_hot": [("BTC", -0.55), ("ETH", -0.50), ("SOL", -0.55)],
"cpi_cool": [("BTC", 0.60), ("ETH", 0.55), ("SOL", 0.50)],
# ── Gold (gold rally often correlates with BTC as alt store-of-value) ──
"gold_breakout": [("BTC", 0.35), ("ETH", 0.15), ("PAXG", 0.90)],
"gold_selloff": [("BTC", -0.20), ("PAXG", -0.85)],
# ── Geopolitical (risk-off = BTC mixed, alts down; safe havens up) ──
"geopolitical_escalation":[("BTC", -0.30), ("ETH", -0.50), ("SOL", -0.60), ("ONDO", -0.40)],
"geopolitical_deesc": [("BTC", 0.25), ("ETH", 0.35), ("SOL", 0.45), ("ONDO", 0.30)],
# ── Trade / Tariff ──
"tariff_escalation": [("BTC", -0.40), ("ETH", -0.45), ("SOL", -0.50)],
"tariff_relief": [("BTC", 0.40), ("ETH", 0.45), ("SOL", 0.50)],
# ── Whale ──
"whale_buy": [("BTC", 0.50), ("ETH", 0.45)],
"whale_sell": [("BTC", -0.55), ("ETH", -0.50)],
# ── Liquidation ──
"liquidation_cascade": [("BTC", -0.60), ("ETH", -0.70), ("SOL", -0.80)],
# ── RWA ──
"rwa_catalyst": [("ONDO", 0.80), ("MKR", 0.40), ("LINK", 0.30), ("ETH", 0.20)],
"sec_rwa_positive": [("ONDO", 0.75), ("MKR", 0.35), ("ETH", 0.30), ("SOL", 0.20)],
"sec_rwa_negative": [("ONDO", -0.70), ("MKR", -0.30), ("ETH", -0.20)],
# ── Employment / GDP ──
"nfp_strong": [("BTC", -0.30), ("ETH", -0.30), ("SOL", -0.35)],
"nfp_weak": [("BTC", 0.40), ("ETH", 0.35), ("SOL", 0.30)],
"gdp_strong": [("BTC", 0.25), ("ETH", 0.20), ("SOL", 0.20)],
"gdp_weak": [("BTC", -0.35), ("ETH", -0.30), ("SOL", -0.30)],
}

# Fallback: generic macro → crypto correlation when event_type is unknown
TOKEN_IMPACT_GENERIC = [("BTC", 0.40), ("ETH", 0.35), ("SOL", 0.30)]

# Dashboard source diversity: minimum signals per source in API response
DASHBOARD_SOURCE_QUOTA = 5
DASHBOARD_MAX_SIGNALS = 80

# ═══════════════════════════════════════════════════════════════════════
# SENTIMENT LEXICON (domain-tuned, weighted)
# ═══════════════════════════════════════════════════════════════════════
Expand Down Expand Up @@ -365,3 +417,50 @@
"MAY", "SAY", "SET", "RUN", "USE", "BIG", "OLD", "LOW", "TOP",
"USD", "EUR", "GBP", "JPY", "CNY",
}

# ═══════════════════════════════════════════════════════════════════════
# WEBSOCKET SERVER (for real-time signal push to consumers)
# ═══════════════════════════════════════════════════════════════════════
WS_ENABLED = True
WS_PORT = 3253 # DASHBOARD_PORT + 1
WS_PING_INTERVAL = 30
WS_PING_TIMEOUT = 10
WS_MAX_CLIENTS = 50

# ═══════════════════════════════════════════════════════════════════════
# WEBHOOK PUSH (fire-and-forget POST to external URLs)
# ═══════════════════════════════════════════════════════════════════════
WEBHOOK_URLS = [] # List of URLs to POST signals to
WEBHOOK_MIN_MAGNITUDE = 0.6
WEBHOOK_EVENTS = [] # Empty = all; else ["fed_cut_surprise", ...]
WEBHOOK_TIMEOUT_SEC = 5

# ═══════════════════════════════════════════════════════════════════════
# CRYPTOPANIC API
# ═══════════════════════════════════════════════════════════════════════
CRYPTOPANIC_ENABLED = True
CRYPTOPANIC_TOKEN = os.environ.get("CRYPTOPANIC_TOKEN", "")
CRYPTOPANIC_BASE = "https://cryptopanic.com/api/v1/posts/"
CRYPTOPANIC_POLL_SEC = 120
CRYPTOPANIC_FILTER = "rising" # "rising" | "hot" | "important" | "all"

# ═══════════════════════════════════════════════════════════════════════
# RSS / ATOM FEED SUPPORT
# ═══════════════════════════════════════════════════════════════════════
RSS_ENABLED = True
RSS_FEEDS = [
# {"url": "https://www.coindesk.com/arc/outboundfeeds/rss/", "category": "crypto_news", "poll_sec": 300, "label": "CoinDesk"},
]
RSS_DEFAULT_POLL_SEC = 300

# ═══════════════════════════════════════════════════════════════════════
# FUZZY DEDUP
# ═══════════════════════════════════════════════════════════════════════
DEDUP_FUZZY_ENABLED = True
DEDUP_FUZZY_THRESHOLD = 0.7 # Jaccard similarity threshold

# ═══════════════════════════════════════════════════════════════════════
# SIGNAL ACCURACY TRACKING
# ═══════════════════════════════════════════════════════════════════════
ACCURACY_ENABLED = True
ACCURACY_CHECK_HOURS = [1, 6, 24] # Check price at +1h, +6h, +24h
Loading
Loading