dr-manhattan
Trade prediction markets (Polymarket, Kalshi, Opinion, Limitless, Predict.fun) using a unified CCXT-style API. Use when the user wants to browse, search, or trade prediction markets, check balances and positions, manage orders, run market-making strategies, or compare prices across exchanges.
Best use case
dr-manhattan is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Trade prediction markets (Polymarket, Kalshi, Opinion, Limitless, Predict.fun) using a unified CCXT-style API. Use when the user wants to browse, search, or trade prediction markets, check balances and positions, manage orders, run market-making strategies, or compare prices across exchanges.
Teams using dr-manhattan should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
How dr-manhattan Compares
| Feature / Agent | dr-manhattan | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Trade prediction markets (Polymarket, Kalshi, Opinion, Limitless, Predict.fun) using a unified CCXT-style API. Use when the user wants to browse, search, or trade prediction markets, check balances and positions, manage orders, run market-making strategies, or compare prices across exchanges.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Dr. Manhattan - Prediction Market Trading
Dr. Manhattan is a unified API for prediction markets, similar to how CCXT works for cryptocurrency exchanges. It supports Polymarket, Kalshi, Opinion, Limitless, and Predict.fun through a single interface.
## Setup
Install dependencies with uv:
```bash
uv venv && uv pip install -e .
```
For MCP server (Claude integration):
```bash
uv sync --extra mcp
```
## Supported Exchanges
| Exchange | Chain/Type | Auth |
|------------- |--------------- |------------------------------------------ |
| Polymarket | Polygon | Private key + funder address |
| Kalshi | Regulated CEX | API key + RSA private key |
| Opinion | BNB Chain | API key + private key + multi-sig address |
| Limitless | Base | Private key |
| Predict.fun | BNB Chain | API key + private key (EOA or smart wallet) |
## Usage as a Python Library
### Read-Only (No Credentials)
```python
import dr_manhattan
polymarket = dr_manhattan.Polymarket({'timeout': 30})
markets = polymarket.fetch_markets()
for market in markets:
print(f"{market.question}: {market.prices}")
```
### With Authentication
```python
import dr_manhattan
polymarket = dr_manhattan.Polymarket({
'private_key': '0x...',
'funder': '0x...',
})
order = polymarket.create_order(
market_id="market_123",
outcome="Yes",
side=dr_manhattan.OrderSide.BUY,
price=0.65,
size=100,
params={'token_id': 'token_id'}
)
```
### Exchange Factory
```python
from dr_manhattan import create_exchange, list_exchanges
print(list_exchanges()) # ['polymarket', 'opinion', 'limitless', 'predictfun', 'kalshi']
exchange = create_exchange('polymarket', {'timeout': 30})
```
## Usage via MCP Server
Dr. Manhattan exposes all trading capabilities as MCP tools. Configure in Claude Code (`~/.claude/settings.json` or `.mcp.json`):
```json
{
"mcpServers": {
"dr-manhattan": {
"command": "/path/to/dr-manhattan/.venv/bin/python",
"args": ["-m", "dr_manhattan.mcp.server"],
"cwd": "/path/to/dr-manhattan"
}
}
}
```
### MCP Tools Reference
**Exchange Tools:**
- `list_exchanges` - List all available prediction market exchanges.
- `get_exchange_info(exchange)` - Get metadata and capabilities for an exchange.
- `validate_credentials(exchange)` - Check if credentials are valid without trading.
**Market Discovery:**
- `search_markets(exchange, query)` - Search markets by keyword. This is the fastest way to find markets about a topic.
- `fetch_markets(exchange, limit?, offset?)` - Fetch all markets with pagination.
- `fetch_market(exchange, market_id)` - Fetch a specific market by ID.
- `fetch_markets_by_slug(exchange, slug)` - Fetch markets by slug or URL (Polymarket, Limitless).
- `find_tradeable_market(exchange, binary?, limit?, min_liquidity?)` - Find a suitable market for trading.
- `find_crypto_hourly_market(exchange, token_symbol?)` - Find crypto hourly price markets (Polymarket).
- `fetch_token_ids(exchange, market_id)` - Get token IDs for a market.
- `parse_market_identifier(identifier)` - Extract slug from a Polymarket URL.
- `get_tag_by_slug(slug)` - Get Polymarket tag information.
**Orderbook:**
- `get_orderbook(exchange, token_id)` - Get full orderbook (bids and asks).
- `get_best_bid_ask(exchange, token_id)` - Get best bid and ask prices.
**Trading:**
- `create_order(exchange, market_id, outcome, side, price, size)` - Place a buy or sell order. Price is 0-1 (probability). Side is "buy" or "sell".
- `cancel_order(exchange, order_id, market_id?)` - Cancel a specific order.
- `cancel_all_orders(exchange, market_id?)` - Cancel all open orders.
- `fetch_order(exchange, order_id, market_id?)` - Get order details and fill status.
- `fetch_open_orders(exchange, market_id?)` - List all open orders.
**Account:**
- `fetch_balance(exchange)` - Get account balance (USDC).
- `fetch_positions(exchange, market_id?)` - Get current positions with PnL.
- `fetch_positions_for_market(exchange, market_id)` - Get positions for a specific market.
- `calculate_nav(exchange, market_id?)` - Calculate net asset value (cash + positions).
**Strategy Management:**
- `create_strategy_session(strategy_type, exchange, market_id, ...)` - Start a market-making strategy in the background.
- `get_strategy_status(session_id)` - Get real-time strategy status (NAV, positions, delta).
- `get_strategy_metrics(session_id)` - Get performance metrics (uptime, fills).
- `pause_strategy(session_id)` - Pause a running strategy.
- `resume_strategy(session_id)` - Resume a paused strategy.
- `stop_strategy(session_id, cleanup?)` - Stop a strategy and optionally cancel orders.
- `list_strategy_sessions` - List all active strategy sessions.
## Common Workflows
### Find and Analyze a Market
1. Use `search_markets` with a keyword to find relevant markets.
2. Pick a market from the results and note its `id` and `metadata.clobTokenIds`.
3. Use `get_orderbook` with a token ID to see current bids and asks.
4. Use `get_best_bid_ask` for a quick spread check.
### Place a Trade
1. Find the market using `search_markets` or `fetch_markets_by_slug`.
2. Check `fetch_balance` to confirm available funds.
3. Get the orderbook with `get_orderbook` to see current prices.
4. Use `create_order` with the market ID, outcome ("Yes" or "No"), side ("buy" or "sell"), price (0-1), and size.
5. Monitor with `fetch_order` or `fetch_open_orders`.
### Run a Market-Making Strategy
1. Find a market with `search_markets` or `find_tradeable_market`.
2. Start with `create_strategy_session(strategy_type="market_making", exchange, market_id)`.
3. Monitor with `get_strategy_status` and `get_strategy_metrics`.
4. Control with `pause_strategy`, `resume_strategy`, or `stop_strategy`.
### Check Portfolio
1. `fetch_balance` to see cash.
2. `fetch_positions` to see all open positions with unrealized PnL.
3. `calculate_nav` for total portfolio value (cash + positions).
## Key Concepts
- **Prices are probabilities** ranging from 0 to 1 (exclusive). A price of 0.65 means the market implies a 65% chance.
- **Outcomes** are typically "Yes" and "No" for binary markets. Their prices sum to approximately 1.
- **Token IDs** are exchange-specific identifiers for each outcome of a market. Needed for orderbook queries.
- **Slugs** are human-readable URL identifiers (e.g., "trump-2024") used by Polymarket and Limitless.
- **Order types** supported: GTC (Good-Til-Cancel), FOK (Fill-Or-Kill), IOC (Immediate-Or-Cancel).
## Running Examples
```bash
uv run python examples/list_all_markets.py polymarket
uv run python examples/spread_strategy.py --exchange polymarket --slug fed-decision
uv run python examples/spike_strategy.py -e opinion -m 813 --spike-threshold 0.02
```
## Data Models
**Market** fields: `id`, `question`, `outcomes`, `prices`, `volume`, `liquidity`, `close_time`, `tick_size`, `description`, `metadata` (contains `slug`, `clobTokenIds`).
**Order** fields: `id`, `market_id`, `outcome`, `side` (BUY/SELL), `price`, `size`, `filled`, `status` (PENDING/OPEN/FILLED/CANCELLED), `time_in_force`.
**Position** fields: `market_id`, `outcome`, `size`, `average_price`, `current_price`. Properties: `cost_basis`, `current_value`, `unrealized_pnl`.
**Orderbook** fields: `bids` (price, size descending), `asks` (price, size ascending). Properties: `best_bid`, `best_ask`, `mid_price`, `spread`.Related Skills
workspace-surface-audit
Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup, then recommend the highest-value ECC-native skills, hooks, agents, and operator workflows. Use when the user wants help setting up Claude Code or understanding what capabilities are actually available in their environment.
ui-demo
Record polished UI demo videos using Playwright. Use when the user asks to create a demo, walkthrough, screen recording, or tutorial video of a web application. Produces WebM videos with visible cursor, natural pacing, and professional feel.
token-budget-advisor
Offers the user an informed choice about how much response depth to consume before answering. Use this skill when the user explicitly wants to control response length, depth, or token budget. TRIGGER when: "token budget", "token count", "token usage", "token limit", "response length", "answer depth", "short version", "brief answer", "detailed answer", "exhaustive answer", "respuesta corta vs larga", "cuántos tokens", "ahorrar tokens", "responde al 50%", "dame la versión corta", "quiero controlar cuánto usas", or clear variants where the user is explicitly asking to control answer size or depth. DO NOT TRIGGER when: user has already specified a level in the current session (maintain it), the request is clearly a one-word answer, or "token" refers to auth/session/payment tokens rather than response size.
skill-comply
Visualize whether skills, rules, and agent definitions are actually followed — auto-generates scenarios at 3 prompt strictness levels, runs agents, classifies behavioral sequences, and reports compliance rates with full tool call timelines
santa-method
Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.
safety-guard
Use this skill to prevent destructive operations when working on production systems or running agents autonomously.
repo-scan
Cross-stack source code asset audit — classifies every file, detects embedded third-party libraries, and delivers actionable four-level verdicts per module with interactive HTML reports.
project-flow-ops
Operate execution flow across GitHub and Linear by triaging issues and pull requests, linking active work, and keeping GitHub public-facing while Linear remains the internal execution layer. Use when the user wants backlog control, PR triage, or GitHub-to-Linear coordination.
product-lens
Use this skill to validate the "why" before building, run product diagnostics, and pressure-test product direction before the request becomes an implementation contract.
openclaw-persona-forge
为 OpenClaw AI Agent 锻造完整的龙虾灵魂方案。根据用户偏好或随机抽卡, 输出身份定位、灵魂描述(SOUL.md)、角色化底线规则、名字和头像生图提示词。 如当前环境提供已审核的生图 skill,可自动生成统一风格头像图片。 当用户需要创建、设计或定制 OpenClaw 龙虾灵魂时使用。 不适用于:微调已有 SOUL.md、非 OpenClaw 平台的角色设计、纯工具型无性格 Agent。 触发词:龙虾灵魂、虾魂、OpenClaw 灵魂、养虾灵魂、龙虾角色、龙虾定位、 龙虾剧本杀角色、龙虾游戏角色、龙虾 NPC、龙虾性格、龙虾背景故事、 lobster soul、lobster character、抽卡、随机龙虾、龙虾 SOUL、gacha。
manim-video
Build reusable Manim explainers for technical concepts, graphs, system diagrams, and product walkthroughs, then hand off to the wider ECC video stack if needed. Use when the user wants a clean animated explainer rather than a generic talking-head script.
laravel-plugin-discovery
Discover and evaluate Laravel packages via LaraPlugins.io MCP. Use when the user wants to find plugins, check package health, or assess Laravel/PHP compatibility.