--- name: polystrike-agent-api description: Finding risk-free arbitrage and prediction market edges on Polymarket using Polystrike data. license: MIT metadata: version: "1.2" subject: "Elon Musk" platform: "Polymarket" # The venue where trades are executed provider: "Polystrike" # The source of the API/Data --- # Polystrike Agent API > **Context**: This skill provides the tools and strategies for AI agents to trade on **Polymarket's** Elon Musk tweet count markets using **Polystrike's** real-time data layer. **Contact**: [@dizpers](https://x.com/dizpers) on X. ## 1. Scope & Capabilities This skill provides a **Real-Time Data Layer** for Polymarket, enabling AI agents to trade with an information advantage. ### A. Market Metadata (Elon Musk) We provide the **Ground Truth** for Elon Musk tweet markets. - **Real-Time Counters**: Precise count of *qualified* tweets vs *settled* tweets. - **Tweet Stream**: Raw feed of every new tweet (including deleted ones) for sentiment analysis. - **State Tracking**: Monitoring of Elon's "Sleep/Wake" state for velocity modeling. **Why it matters**: Polymarket's UI varies by 30s-5m from reality. Without this metadata, you are trading blind. With it, you can front-run settlement. ### B. Alpha Detection - **Detect Arbitrage**: Find "risk-free" trades where the Polystrike settlement count is ahead of the official oracle. - **Monitor Latency**: Track the `display_delta` (UI lag) to exploit retail traders' delayed data. ### C. Predictive Modeling & Signals (Pro Only) - **Forecast Outcomes**: Access Monte Carlo simulations (1000 runs) that account for sleep schedules and mean reversion. - **EV-Based Signals**: Receive actionable `BUY` / `SELL` signals automatically optimized for Expected Value (EV), with optimal Kelly Criterion bet sizing and Information Asymmetry Edge detection. **Current Scope**: Elon Musk Tweet Count Markets only. ## 2. Access Methods ### A. MCP Server (Recommended for AI Assistants) **Model Context Protocol (MCP)** provides native integration for AI assistants like Claude Desktop. Instead of making HTTP requests, the assistant can query Polystrike through natural language. **MCP Server URL**: `https://polystrike.xyz/mcp/sse` **Configuration** (for Claude Desktop): ```json { "mcpServers": { "polystrike": { "command": "npx", "args": [ "-y", "mcp-remote", "https://polystrike.xyz/mcp/sse", "--header", "x-api-key:${POLYSTRIKE_API_KEY}" ], "env": { "POLYSTRIKE_API_KEY": "your_api_key_here" } } } } ``` **Available MCP Tools**: - `get_market_metadata` - Active Elon tweet markets - `get_recent_tweets` - Recent tweets (15 for FREE, 100 for PRO) - `get_predictions` - Market predictions (limited for FREE, full for PRO) - `get_trading_signals` - EV-based signals with Kelly sizing (PRO only) - `analyze_portfolio` - Wallet position analysis (PRO only) - `check_health` - API health status **Benefits**: - Natural language queries instead of HTTP requests - Automatic authentication via API key - Real-time data access - No local installation (runs on Polystrike infrastructure) ### B. OpenAPI Specification For machine-readable API discovery, fetch the OpenAPI spec: ```bash curl https://polystrike.xyz/openapi.json ``` **For AI Agents:** The OpenAPI spec provides structural information (endpoints, parameters, types, authentication). This SKILL.md provides contextual information (when to use, why, gotchas, oracle lag, Kelly sizing). Use both together for complete understanding. **What OpenAPI Provides:** - All endpoint paths and HTTP methods - Request parameters and types - Authentication schemes (X-API-Key, x402) - Tier information (FREE vs PRO) - Endpoint descriptions and tags ### C. Direct HTTP API For custom integrations, bots, or non-MCP environments, use the direct HTTP API. **Authentication Tiers**: 1. **Anonymous (Public)** - **No Key Required** - **Rate Limit**: 100 requests/hour - **Access**: Metadata, Counters, Delta tracking. Perfect for lag-based arbitrage. 2. **Pro ($79/mo)** - **Requires Key**: `X-API-Key: ps_pro_...` - **Rate Limit**: 10,000 requests/hour - **Access**: Forecasts (`p5`/`p95`), EV-Based Trade Signals, `is_counted` flag on tweets, Portfolio Analysis. - **Upgrade**: Contact [@dizpers](https://x.com/dizpers) or `dizpers@gmail.com`. **Base URL**: `https://polystrike.xyz/api/v1` ## 3. Endpoints & Strategies ### 1. Market Metadata (The Ground Truth) **Endpoint**: `GET /api/v1/meta/elon` **Tier**: **Public** (Free) **Goal**: Identify arbitrage opportunities via counters and deltas. ```bash curl https://polystrike.xyz/api/v1/meta/elon ``` **Response**: ```json { "timestamp": 1770733363222, "data": [ { "event_id": 194167, "event_title": "Elon Musk # tweets Feb 3-10", "polymarket_xtracker_counter": 215, // Settlement (Oracle) "real_counter": 220, // Reality (Ground Truth) "polymarket_ui_counter": 215, // Display (Website) "settlement_delta": 5, // real - xtracker "display_delta": 5, // real - ui "internal_delta": 0 // ui - xtracker } ] } ``` **Key Fields**: - `settlement_delta`: The gap between Reality and Oracle. If `> 0`, **Buy YES**. You know the count will rise. - `display_delta`: The gap between Reality and UI. If `> 5`, **Front-run UI**. Retail is blind to recent tweets. - `real_counter`: The actual number of qualified tweets sent by Elon. - `polymarket_xtracker_counter`: The number currently recognized by the UMA oracle/Polymarket settlement. --- ### 2. Tweet Stream (Sentiment & Velocity) **Endpoint**: `GET /api/v1/meta/elon/tweets` **Tier**: **Public** (Masked) / **Pro** (Full) **Goal**: Analyze raw tweet content or detect deletions. **Query Parameters (Pro Only)**: - `limit`: Number of tweets to return (max 100). - `offset`: Number of tweets to skip. > **Note**: Free users are fixed at the latest **15 tweets**. Query parameters are ignored. ```bash curl https://polystrike.xyz/api/v1/meta/elon/tweets ``` **Response (Public)**: ```json { "timestamp": 1770734408963, "data": [ { "tweet_id": "2021230513298473031", "text": "SpaceX is launching...", "created_ts": 1770733881000, "is_reply": false, "is_quote": false, "is_retweet": false, "is_counted": null // Pro users see true/false } ], "limit": 15, "offset": 0 } ``` **Key Fields**: - `text`: The raw content of the tweet. - `is_counted`: **Pro Only**. Returns `true` if the tweet counts towards the market resolution (filtering replies/retweets). Public users see `null`. - `created_ts`: Unix timestamp of the tweet (in milliseconds). --- ### 3. Prediction Model (Monte Carlo) **Endpoint**: `GET /api/v1/prediction/elon` **Tier**: **Pro Only** (for forecasts) **Goal**: Forecast the final count using our sleep-aware model. ```bash curl -H "X-API-Key: ps_pro_..." https://polystrike.xyz/api/v1/prediction/elon ``` **Response (Pro)**: ```json { "timestamp": 1770733363222, "data": [ { "event_id": 194167, "seconds_remaining": 43200, "forecast": { "p5": 224, // 5% chance count < 224 "p50": 242, // Median forecast "p95": 272 // 95% chance count < 272 }, "markets": [ { "title": "240-259", "model_prob": 0.45, "market_price": 0.35, "edge": 0.10, "signal": "BUY" } ] } ] } ``` **Key Fields**: - `forecast`: Probabilistic outcome range. `p5` is the floor, `p95` is the ceiling. - `model_prob`: The probability of the outcome falling in this bucket according to our simulation. - `market_price`: The current price on Polymarket (implied probability). - `signal`: Trading recommendation (`BUY`, `SELL`, `HOLD`). --- ### 4. EV-Based Signals **Endpoint**: `GET /api/v1/signals/elon` **Tier**: **Pro Only** **Goal**: Get a sorted list of actionable trading signals optimizing for Expected Value (EV). **Parameters**: | Parameter | Required | Description | |-----------|----------|-------------| | `bankroll` | No | Your bankroll in USD (1-1,000,000). If provided, `suggested_bet` is sized to your bankroll via Kelly criterion. If omitted, a server default is used. | ```bash curl -H "X-API-Key: ps_pro_..." "https://polystrike.xyz/api/v1/signals/elon?bankroll=100" ``` **Response**: ```json { "timestamp": 1771246739535, "data": [ { "event_id": 206602, "signals": [ { "bucket": "65-89", "action": "BUY", "model_prob": 1.0, "market_price": 0.945, "edge": 0.055, "ev": 0.058, "kelly_fraction": 0.058, "suggested_bet": 5.80, "confidence": "HIGH", "moneyness": 0.5, "time_confidence": "HIGH", "asymmetry_edge": 0, "reasons": [ "Strong signal: 100% prob, +5.8% EV" ], "timestamp": 1771246739535, "bankroll": 100.0 } ] } ] } ``` --- ### 5. Portfolio Analysis **Endpoint**: `GET /api/v1/portfolio/elon?wallet=0x...` **Tier**: **Pro Only** **Goal**: Fetch your open positions from Polymarket and overlay model predictions to get hold/sell signals for each bucket. ```bash curl -H "X-API-Key: ps_pro_..." "https://polystrike.xyz/api/v1/portfolio/elon?wallet=0xYourWalletAddress" ``` **Response**: ```json { "timestamp": 1771246750000, "data": [ { "wallet": "0xYourWalletAddress", "event": { "id": 206602, "title": "Elon Musk # tweets February 14 - February 16, 2026?", "end_ts": 1771261200000 }, "prediction": { "p5": 68, "p50": 72, "p95": 78, "real_counter": 68, "seconds_remaining": 14528, "velocity_counted_1h": 4.2 }, "positions": [ { "event_id": "206602", "bucket": "65-89", "tokens": 50.0, "avg_price": 0.82, "cost_basis": 41.00, "current_price": 0.945, "current_value": 47.25, "pnl": 6.25, "pnl_percent": 15.24, "analysis": { "win_probability": 1.0, "market_implied": 0.945, "edge": 0.055, "edge_percent": 5.82, "signal": "BUY", "recommendation": "HOLD" } } ], "portfolio": { "total_positions": 1, "total_cost": 41.00, "current_value": 47.25, "total_pnl": 6.25, "total_pnl_percent": 15.24 } } ] } ``` **Key Fields**: - `prediction.velocity_counted_1h`: Tweets per hour over the last hour — useful for projecting remaining count. - `positions[].analysis.signal`: `STRONG_BUY` (edge_pct>30%), `BUY` (>10%), `HOLD` (>0%), `AVOID` (>-10%), `SELL` (≤-10%). - `positions[].analysis.recommendation`: `STRONG_HOLD` (edge>0.20), `HOLD` (>0.05), `MONITOR` (>-0.05), `CONSIDER_SELLING` (≤-0.05). - `signal` uses edge as % of market price (good for deciding to *add*). `recommendation` uses raw edge (good for deciding to *exit*). --- ## 4. Integration Examples ### Example: Arbitrage Bot (Python / Public Tier) ```python import aiohttp import asyncio async def check_arb(): async with aiohttp.ClientSession() as session: # 1. Fetch Metadata (Public Endpoint) async with session.get("https://polystrike.xyz/api/v1/meta/elon") as resp: data = await resp.json() for event in data["data"]: # 2. Check for Settlement Lag (God View) if event["settlement_delta"] > 0: print(f"🚨 ARB: Oracle is behind by {event['settlement_delta']} tweets!") # BUY YES on current bucket # 3. Check for UI Lag (Front-Running) if event["display_delta"] > 5: print(f"⚡ SPEED: UI is lagging by {event['display_delta']} tweets.") # BUY YES before UI updates ``` --- ## 5. Risk Warnings - **Deleted Tweets**: Polystrike captures tweets within seconds. If Elon later deletes a tweet we already captured, it remains in `real_counter` (flagged `is_deleted: true`). XTracker may never have seen it, so `settlement_delta` stays positive — but that tweet will NOT count toward settlement. This means `settlement_delta` driven by deletions is not a true arbitrage edge. - *Mitigation*: Check the tweet feed for `is_deleted` flags (Pro only). Prefer `settlement_delta >= 2` from non-deleted tweets before acting. - **Model Variance**: Predictions >48h out have ±40% error bars. Trust the model signals (`p5`/`p95`) mainly in the final 24h. --- built with 🤖 by [Polystrike](https://polystrike.xyz)