Trend-to-Trade Signal Feed
Absorb signals from across the internet — trends, news, social chatter — charge them with intelligence, and discharge matched predictions and trades when you need them.
Product Scope
Enter the terminal. Paste a link to an X post or news article. System scrapes content, analyzes with LLM, returns matched Polymarket predictions + HyperLiquid perps. No auth required.
React Native app. Privy auth with social login. Calibrate the terminal to show markets that matter to you. Auto-generated trending feed with market overlays. Social data enrichment from X and Farcaster.
System Architecture
Tech Stack
| Layer | Technology | Rationale |
|---|---|---|
| Mobile Client | React Native (Expo) | Cross-platform, Privy RN SDK support |
| Web Client | Next.js | Prototype-first, SSR for SEO |
| API Server | Node.js + Hono | Fast, typed, edge-compatible |
| Database | PostgreSQL (Supabase) | Managed, real-time subscriptions |
| Cache / Queue | Redis (Upstash) + BullMQ | Serverless Redis, reliable job queues |
| LLM | GPT-4o / 4o-mini | Best cost/quality for classification |
| Image Gen | DALL-E 3 / Flux | Editorial illustrations for feed cards |
| Hosting | Vercel + Fly.io | Vercel for web, Fly for API workers |
Polymarket API
Prediction market data — completely free, no auth required. Three API surfaces.
Gamma API — Discovery & Search
gamma-api.polymarket.com · 4,000 req / 10s
| Endpoint | Purpose | Key Params |
|---|---|---|
GET /public-search?q={query} | Search markets by keyword | q (search string) |
GET /events | List/filter events | limit, offset, active, closed, order, tag |
GET /markets | List/filter markets | limit, offset, active, closed, order, slug |
GET /tags | List category tags | none |
⚠ DOUBLE-ENCODED FIELDS: outcomePrices, clobTokenIds, outcomes are JSON strings inside JSON. Parse with json.loads() in Python or JSON.parse() in JS.
CLOB API — Real-time Prices
clob.polymarket.com · 9,000 req / 10s
| Endpoint | Purpose | Params |
|---|---|---|
GET /price?token_id={ID}&side=buy | Current price | token_id, side |
GET /midpoint?token_id={ID} | Mid price | token_id |
GET /book?token_id={ID} | Full orderbook | token_id |
GET /prices-history?market={CID} | Price history | market, interval, fidelity |
Data API — Trades & Open Interest
data-api.polymarket.com · 1,000 req / 10s
| Endpoint | Purpose |
|---|---|
GET /trades?market={CID} | Recent trades |
GET /oi?market={CID} | Open interest |
HyperLiquid API
Perpetual futures data — free, no auth for reads. Single POST endpoint, type field determines query.
| Type | Body | Returns |
|---|---|---|
meta | {"type":"meta"} | All perp assets: name, decimals, maxLeverage |
metaAndAssetCtxs | {"type":"metaAndAssetCtxs"} | Meta + live prices, funding, OI, volume |
allMids | {"type":"allMids"} | Current mid prices for all assets |
l2Book | {"type":"l2Book","coin":"BTC"} | Orderbook (bids/asks) |
candleSnapshot | {"type":"candleSnapshot","coin":"BTC","interval":"1h",...} | OHLCV candle data |
fundingHistory | {"type":"fundingHistory","coin":"BTC",...} | Funding rate history |
recentTrades | {"type":"recentTrades","coin":"BTC"} | Last trades for asset |
Response: metaAndAssetCtxs
X / Twitter API
10K tweet reads/mo, search recent, single tweet fetch. Sufficient for link-drop and limited search.
⚠ TRENDING TOPICS = PRO TIER ($5,000/MO)
SocialData.tools: $49/mo — full Twitter-like API, no rate pain.
Apify scrapers: Pay-per-use — scraper actors for tweets and trends.
Link Drop: Tweet Extraction
News & Article Scraping
News Aggregation APIs
| API | Free Tier | Endpoint | Best For |
|---|---|---|---|
| NewsAPI.org | 100 req/day | /v2/top-headlines?category= | Headlines by category |
| GNews.io | 100 req/day | /api/v4/top-headlines | Backup source |
| CryptoPanic | Free w/ key | /api/v1/posts/?filter=hot | Crypto + sentiment |
| CoinGecko | 30 req/min | /api/v3/search/trending | Trending coins |
Article Content Extraction
https://r.jina.ai/{url} — returns clean markdown. Handles JS rendering, anti-bot. Zero config.
Self-host Mozilla Readability for speed. Firecrawl API (generous free tier) for complex pages.
Trend Sources
| Source | Endpoint | Auth | Cost |
|---|---|---|---|
| Google Trends | serpapi.com/google-trends-api | API key | Free 100/mo |
GET /r/{sub}/hot.json | Optional | Free | |
| Farcaster | api.neynar.com/v2/farcaster/feed/trending | API key | Free 300 req/min |
| Hacker News | hn.algolia.com/api/v1/search | None | Free |
| CoinGecko | api.coingecko.com/api/v3/search/trending | Optional | Free 30 req/min |
| DeFi Llama | api.llama.fi/protocols | None | Free |
Farcaster via Neynar
Privy Authentication
Single SDK. Social + wallet auth. Web and React Native.
Supported Login Methods
Data Returned Post-Auth
Privy returns identity (username, pfp) but NOT social graph (followers, interests, liked posts). Workaround:
• Farcaster: Neynar API with FID → follower graph + activity
• X: Bearer token → public timeline (limited on Basic)
Database Schema
7 tables. PostgreSQL. Users, content, and market data.
id · privy_id · display_name · avatar_url
x_username · x_user_id
farcaster_fid · farcaster_username
created_at · updated_at
id · user_id (FK)
category [crypto|politics|sports|ai|...]
weight (adjustable via engagement)
id · source · category · title · summary
image_url · source_url · source_data (JSONB)
keywords[] · entities[]
relevance_score · expires_at
id · source [polymarket|hyperliquid]
external_id · market_type [prediction|perp]
title · category · current_price
volume_24h · open_interest · metadata (JSONB)
id · topic_id (FK) · market_id (FK)
match_score (0-1)
match_reason (LLM explanation)
id · user_id (FK) · topic_id (FK)
position · seen · engaged
created_at
id · url (unique) · content_type [tweet|article] · title · body_text · author · keywords[] · entities[] · summary
API Endpoints
Auth & Users
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| POST | /api/auth/verify | — | Verify Privy JWT, upsert user |
| GET | /api/users/me | Bearer | Current user + interests |
| PUT | /api/users/me/interests | Bearer | Set interest categories |
| POST | /api/users/me/enrich | Bearer | Fetch social data, infer interests |
Link Drop — Scrape & Match
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| POST | /api/scrape | Optional | Scrape URL → text, keywords, entities |
| POST | /api/match | Optional | Keywords/entities → matched markets |
| POST | /api/analyze-link | Optional | Combined scrape + match |
Feed
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| GET | /api/feed?page=&limit=&category= | Bearer | Personalized feed with markets |
| GET | /api/feed/refresh | Bearer | Force-refresh |
Markets — Direct Query
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /api/markets/polymarket/trending | Top predictions by volume |
| GET | /api/markets/polymarket/search?q= | Search predictions |
| GET | /api/markets/hyperliquid/assets | All perps with prices |
| GET | /api/markets/hyperliquid/:coin | Detailed perp data |
Background Jobs
5 pipelines. BullMQ on Redis. Continuous charge cycle.
01. Trend Polling — Every 15 Min
Parallel fetch from all sources:
Dedup via fuzzy title match (Levenshtein < 0.3). Classify via GPT-4o-mini. Store in trending_topics.
02. Summarize + Image Gen
GPT-4o writes 2-3 sentence summary. Extracts keywords. DALL-E 3 generates editorial illustration per feed card.
03. Market Matching
Search Polymarket by keywords/entities. Map HyperLiquid assets via entity→ticker lookup. LLM scores relevance 0-1. Keep > 0.5.
04. Price Refresh — Every 5 Min
Batch update cached market prices. Polymarket via CLOB endpoint. HyperLiquid via single allMids call.
05. Feed Generation — Every 30 Min
Per-user: filter by interests, join market matches, rank, apply diversity rules.
LLM Strategy
| Task | Model | Tokens | Frequency | Cost/Cycle |
|---|---|---|---|---|
| Topic categorization | gpt-4o-mini | ~200 | 100/cycle | $0.003 |
| Summary generation | gpt-4o | ~500 | 100/cycle | $0.250 |
| Keyword extraction | gpt-4o-mini | ~200 | 100/cycle | $0.003 |
| Market scoring | gpt-4o-mini | ~300 | 500/cycle | $0.015 |
| Image prompts | gpt-4o-mini | ~200 | 50/cycle | $0.001 |
| Link analysis | gpt-4o | ~1000 | on-demand | $0.005/req |
$0.30/cycle · $7.20/day @ 4 cycles/hr · ~$10-15/day with caching
Matching Algorithm
Polymarket Matching Pipeline
Top 5 keywords → GET /public-search?q={keyword}
Named entities (person, org, event) → Polymarket search
Remove duplicates by conditionId
Active only. Volume > $1,000
GPT-4o-mini rates relevance 0-1 per topic-market pair
Score > 0.5, sorted descending
HyperLiquid Matching
Feed Ranking Formula
Implementation Phases
Cost Projections
Prototype — ~$130/mo
Production @ 10K Users — ~$1,328/mo
Key Tradeoffs
Keyword search hits too many false positives. "Trump" matches dozens of markets. LLM understands a tariff tweet → tariff market, not primary market. Cost: ~$0.015/500 pairs.
X streaming = Enterprise ($$$). Most sources lack streaming. 15-min poll is fresh enough. Exception: HL WebSocket for live prices.
Zero infra. Handles JS/anti-bot. Free. Production: add Firecrawl backup, self-host Readability for speed.
Pre-compute per-user feeds. Lower latency, enables push notifications. Trade: up to 30 min stale.
End-to-End Example
Link Drop Flow
https://x.com/elonmusk/status/1234567890
X post detected → fetch tweet → "Spoke with NVIDIA CEO about AI chip exports to China"
Keywords: nvidia, AI chips, China · Entities: NVIDIA, China, Musk · Sentiment: neutral
"US ban AI chip exports to China by 2025?" — 42% Yes ($2.1M vol)
NVIDIA-PERP: $145.20, +0.003% funding, $48M vol
Feed card: tweet summary + prediction markets + perps
Sample Feed Card
The Fed indicated a likely 25bps rate cut at the September meeting, citing cooling inflation and labor market normalization.
Future Enhancements
Trade matched markets via Privy embedded wallet
Follow others. See what markets they watch.
"Notify when this market moves 10%+"
Deep-dive any topic with citations
Connect wallet. Show P&L tied to feed.
Create and share market analysis cards