Agent skill

Trading Polymarket

by alsk1992 in alsk1992/CloddsBot

Execute trades on Polymarket using pyclobclient - full API access for market data, orders, positions

MITAuto-check passedBusiness, Finance & HR

Install Trading Polymarket

skills CLI
$ npx skills add alsk1992/CloddsBot --skill trading-polymarket -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install alsk1992/CloddsBot trading-polymarket --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/alsk1992/CloddsBot.git skills-src && mkdir -p .claude/skills && cp -r skills-src/src/skills/bundled/trading-polymarket .claude/skills/trading-polymarket && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
trading-polymarket
GitHub stars
3k
Token cost
~8.3k tokens
SKILL.md length
1,023 words
Files
2
Skills in repo
116
Repo updated
First seen
Licence
MIT

At a glance

Execute trades on Polymarket using pyclobclient - full API access for market data, orders, positions

  • Tasks that involve Trading and backtesting
  • SKILL.md covers Required Environment Variables, Installation, Authentication Levels and ClobClient - Complete API (60+…, plus 6 more sections
  • Runs TypeScript scripts from its folder; calls pip; reaches clob.polymarket.com and polygon-rpc.com; needs POLY_API_KEY and POLY_API_SECRET
  • Tasks that involve Stock and market analysis

What it does

Trading Polymarket is an agent skill from alsk1992/CloddsBot. Execute trades on Polymarket using pyclobclient - full API access for market data, orders, positions

Its SKILL.md is about 8.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `index.ts`).

It sits in Business, Finance & HR, covering Trading and backtesting and Stock and market analysis. It works with Polymarket. The repository describes itself as: Open Source AI trading agent that operates autonomously across 1000+ markets - Polymarket, Kalshi, Binance, Hyperliquid, Solana DEXs, 5 EVM chains. Scans for edge, executes… The licence is MIT.

When your agent uses it

  • Tasks that involve Trading and backtesting
  • Tasks that involve Stock and market analysis

Example prompts

  • “/trading-polymarket”

Requirements

  • Python 3
  • Node.js
  • A credential in POLY_API_KEY
  • A credential in POLY_API_SECRET

What it can do on your machine

Read from SKILL.md and the folder at commit c930628. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (TypeScript), which the agent can run.

    Shell commands in SKILL.md call:

    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • clob.polymarket.com
    • polygon-rpc.com
    • gamma-api.polymarket.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • POLY_API_KEY
    • POLY_API_SECRET
    • PRIVATE_KEY
    • API_KEY
    • API_SECRET

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Trading Polymarket loads about 8.3k tokens when it runs. Until then it costs about 30 tokens; SKILL.md has 1,023 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~30
When it runs · the whole SKILL.md, loaded when a task matches
~8.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from alsk1992/CloddsBot at commit c930628, republished under its MIT licence (© alsk1992). 1,023 words, ~8,276 tokens.

Download SKILL.mdSave it as .claude/skills/trading-polymarket/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
trading-polymarket
description
Execute trades on Polymarket using py_clob_client - full API access for market data, orders, positions
emoji
💰
gates.envs
POLY_API_KEY, POLY_API_SECRET, POLY_API_PASSPHRASE, PRIVATE_KEY

Polymarket Trading - Complete API Reference

Full access to Polymarket's CLOB (Central Limit Order Book) via the official py_clob_client library.

60+ methods documented. This is the complete reference.

Required Environment Variables

bash
PRIVATE_KEY=0x...           # Ethereum private key for signing
POLY_FUNDER_ADDRESS=0x...   # Your wallet address on Polygon
POLY_API_KEY=...            # From Polymarket API
POLY_API_SECRET=...         # Base64 encoded secret
POLY_API_PASSPHRASE=...     # API passphrase

Installation

bash
pip install py-clob-client requests

Authentication Levels

LevelRequirementsCapabilities
L0NoneRead-only: orderbooks, prices, markets
L1Private keyCreate & sign orders (not post)
L2Private key + API credsFull trading: post orders, cancel, query
Signature Types
TypeUse Case
0Standard EOA (MetaMask, hardware wallets)
1Magic/email wallets (delegated signing)
2Proxy wallets (Gnosis Safe, browser proxy)

ClobClient - Complete API (60+ Methods)

Initialization
python
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import (
    OrderArgs, MarketOrderArgs, ApiCreds, OrderType,
    BookParams, TradeParams, OpenOrderParams, BalanceAllowanceParams,
    AssetType, OrderScoringParams, OrdersScoringParams, DropNotificationParams
)
from py_clob_client.order_builder.constants import BUY, SELL
from py_clob_client.constants import POLYGON  # 137

# Level 2 Auth (full trading access)
client = ClobClient(
    host="https://clob.polymarket.com",
    key=os.getenv("PRIVATE_KEY"),           # Private key for signing
    chain_id=POLYGON,                        # 137 for mainnet, 80002 for Amoy testnet
    funder=os.getenv("POLY_FUNDER_ADDRESS"), # Wallet address (for proxy wallets)
    signature_type=2                         # 0=EOA, 1=MagicLink, 2=Proxy
)

# Set API credentials for authenticated endpoints
client.set_api_creds(ApiCreds(
    api_key=os.getenv("POLY_API_KEY"),
    api_secret=os.getenv("POLY_API_SECRET"),
    api_passphrase=os.getenv("POLY_API_PASSPHRASE")
))
Health & Configuration
python
client.get_ok()                    # Check if server is up
client.get_server_time()           # Get server timestamp
client.get_address()               # Your signer's public address
client.get_collateral_address()    # USDC contract address
client.get_conditional_address()   # CTF contract address
client.get_exchange_address()      # Exchange contract (neg_risk=False default)
Market Data - Single Token
python
# Get prices and spreads
client.get_midpoint(token_id)              # Mid market price
client.get_price(token_id, side="BUY")     # Best price for side
client.get_spread(token_id)                # Current spread
client.get_last_trade_price(token_id)      # Last executed trade price

# Get full orderbook
orderbook = client.get_order_book(token_id)
# Returns: OrderBookSummary with bids, asks, tick_size, neg_risk, timestamp, hash
Market Data - Batch (Multiple Tokens)
python
params = [
    BookParams(token_id="TOKEN1", side="BUY"),
    BookParams(token_id="TOKEN2", side="SELL")
]

client.get_midpoints(params)           # Multiple midpoints
client.get_prices(params)              # Multiple prices
client.get_spreads(params)             # Multiple spreads
client.get_order_books(params)         # Multiple orderbooks
client.get_last_trades_prices(params)  # Multiple last prices
Market Metadata
python
client.get_tick_size(token_id)      # Returns: "0.1", "0.01", "0.001", or "0.0001"
client.get_neg_risk(token_id)       # Returns: True/False (negative risk market)
client.get_fee_rate_bps(token_id)   # Returns: fee rate in basis points (0 or 1000)

Order Types

python
from py_clob_client.clob_types import OrderType

OrderType.GTC   # Good Till Cancelled - stays open until filled/cancelled
OrderType.FOK   # Fill Or Kill - fill entirely immediately or cancel
OrderType.GTD   # Good Till Date - expires at timestamp (min 60 seconds)
OrderType.FAK   # Fill And Kill - fill what's possible, cancel rest
When to Use Each Order Type
TypeUse CaseExample
GTCEntries - wait for fillPlace buy at 0.45, wait for dip
FOKExits - need immediate fillMarket sell entire position NOW
GTDTime-limited ordersOffer expires in 5 minutes
FAKPartial fills OKGet as much as possible now
OrderArgs - Limit Orders
python
OrderArgs(
    token_id: str,           # Token ID (outcome to trade)
    price: float,            # Price 0.01-0.99
    size: float,             # Number of shares
    side: str,               # "BUY" or "SELL" (or use BUY/SELL constants)
    fee_rate_bps: int = 0,   # Optional: fee rate in bps (0 or check market)
    nonce: int = 0,          # Optional: unique nonce for cancellation
    expiration: int = 0,     # Optional: expiry timestamp (0 = GTC, use timestamp for GTD)
    taker: str = ZERO_ADDRESS  # Optional: specific taker (ZERO_ADDRESS = anyone)
)
MarketOrderArgs - Market Orders
python
MarketOrderArgs(
    token_id: str,           # Token ID
    amount: float,           # Total USDC amount to spend (BUY) or shares (SELL)
    side: str,               # "BUY" or "SELL"
    price: float = 0,        # Optional: worst acceptable price (slippage protection)
    fee_rate_bps: int = 0,   # Optional: fee rate
    nonce: int = 0,          # Optional: nonce
    taker: str = ZERO_ADDRESS,  # Optional: taker address
    order_type: OrderType = FOK  # Optional: FOK (default) or FAK
)
Complete Order Examples
python
from py_clob_client.order_builder.constants import BUY, SELL

# 1. LIMIT BUY (GTC) - sits on book until filled
order = client.create_and_post_order(
    OrderArgs(token_id=TOKEN_ID, price=0.45, size=100.0, side=BUY)
)

# 2. LIMIT SELL (GTC)
order = client.create_and_post_order(
    OrderArgs(token_id=TOKEN_ID, price=0.55, size=50.0, side=SELL)
)

# 3. MARKET BUY - spend $100 USDC at current prices (FOK)
signed = client.create_market_order(
    MarketOrderArgs(token_id=TOKEN_ID, amount=100.0, side=BUY)
)
result = client.post_order(signed, orderType=OrderType.FOK)

# 4. MARKET SELL - sell all shares immediately (FOK)
signed = client.create_market_order(
    MarketOrderArgs(token_id=TOKEN_ID, amount=my_shares, side=SELL)
)
result = client.post_order(signed, orderType=OrderType.FOK)

# 5. POST-ONLY MAKER ORDER (avoid taker fees, earn rebates)
signed = client.create_order(
    OrderArgs(token_id=TOKEN_ID, price=0.44, size=100.0, side=BUY)
)
result = client.post_order(signed, orderType=OrderType.GTC, post_only=True)
# If order would cross spread, it gets REJECTED instead of taking

# 6. GOOD TIL DATE (GTD) - expires after timestamp
import time
expiry = int(time.time()) + 300  # 5 minutes from now
signed = client.create_order(
    OrderArgs(token_id=TOKEN_ID, price=0.50, size=100.0, side=BUY, expiration=expiry)
)
result = client.post_order(signed, orderType=OrderType.GTD)

# 7. FILL AND KILL (FAK) - fill what you can, cancel rest
signed = client.create_market_order(
    MarketOrderArgs(token_id=TOKEN_ID, amount=1000.0, side=BUY)
)
result = client.post_order(signed, orderType=OrderType.FAK)

Order Operations

Create and Post Orders
python
# SIMPLE: Create and post in one call (recommended)
result = client.create_and_post_order(
    OrderArgs(
        token_id="123456789012345678901234567890",
        price=0.45,
        size=10.0,
        side="BUY"
    )
)
# Returns: {"orderID": "...", "status": "...", ...}

# ADVANCED: Separate create and post
order = client.create_order(OrderArgs(...))  # Returns SignedOrder
result = client.post_order(order, orderType=OrderType.GTC, post_only=False)

# Market order (calculates price automatically)
result = client.create_market_order(
    MarketOrderArgs(
        token_id="...",
        amount=100.0,    # Spend $100 USDC
        side="BUY"
    )
)

# Calculate expected fill price before market order
price = client.calculate_market_price(
    token_id="...",
    side="BUY",
    amount=100.0,
    order_type=OrderType.FOK
)
Cancel Orders
python
client.cancel(order_id="ORDER_ID")           # Cancel specific order
client.cancel_orders(["ID1", "ID2", "ID3"])  # Cancel multiple
client.cancel_all()                          # Cancel ALL open orders
client.cancel_market_orders(                 # Cancel by market/asset
    market="CONDITION_ID",
    asset_id="TOKEN_ID"
)
Query Orders
python
# Get all open orders
orders = client.get_orders(
    params=OpenOrderParams(
        id="ORDER_ID",      # Optional: specific order
        market="COND_ID",   # Optional: filter by market
        asset_id="TOKEN"    # Optional: filter by token
    ),
    next_cursor="MA=="      # For pagination
)

# Get specific order
order = client.get_order(order_id="ORDER_ID")
Trade History
python
trades = client.get_trades(
    params=TradeParams(
        id="TRADE_ID",           # Optional: specific trade
        maker_address="0x...",   # Optional: filter by maker
        market="CONDITION_ID",   # Optional: filter by market
        asset_id="TOKEN_ID",     # Optional: filter by token
        before="2024-01-01",     # Optional: before date
        after="2023-01-01"       # Optional: after date
    ),
    next_cursor="MA=="
)
Balance & Allowance
python
# Check balance and allowances
balance = client.get_balance_allowance(
    params=BalanceAllowanceParams(
        asset_type=AssetType.COLLATERAL,  # USDC balance
        # or AssetType.CONDITIONAL         # Token balance
        token_id="TOKEN_ID"                # For conditional tokens
    )
)

# Update/refresh allowance cache
client.update_balance_allowance(params=...)

Market Discovery

Get Markets from CLOB
python
# All active markets
markets = client.get_markets(next_cursor="MA==")
simplified = client.get_simplified_markets()

# Specific market
market = client.get_market(condition_id="CONDITION_ID")

# Market trade events
events = client.get_market_trades_events(condition_id="CONDITION_ID")

# Sampling/featured markets
client.get_sampling_markets()
client.get_sampling_simplified_markets()
Get Markets from Gamma API (More Details)
python
import requests

def search_markets(query: str, limit: int = 10):
    """Search Polymarket markets by keyword"""
    url = "https://gamma-api.polymarket.com/markets"
    params = {
        "_q": query,
        "active": "true",
        "closed": "false",
        "_limit": limit
    }
    r = requests.get(url, params=params)
    return r.json()

# Get market details
markets = search_markets("bitcoin")
for m in markets:
    print(f"Question: {m['question']}")
    print(f"Condition ID: {m['condition_id']}")
    print(f"Volume: ${m.get('volume', 0):,.2f}")
    for token in m.get('tokens', []):
        print(f"  {token['outcome']}: {token['token_id']}")
        print(f"    Price: {float(token['price']):.2f}")

On-Chain Operations

Check Token Balance (Position Size)
python
import requests

CTF_CONTRACT = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
RPC_URL = "https://polygon-rpc.com/"

def get_token_balance(wallet: str, token_id: str) -> float:
    """Get balance of a specific outcome token in shares"""
    token_int = int(token_id)
    # ERC-1155 balanceOf(address,uint256)
    data = f"0x00fdd58e000000000000000000000000{wallet[2:].lower()}{token_int:064x}"

    r = requests.post(RPC_URL, json={
        "jsonrpc": "2.0",
        "method": "eth_call",
        "params": [{"to": CTF_CONTRACT, "data": data}, "latest"],
        "id": 1
    })

    result = r.json().get("result", "0x0")
    balance = int(result, 16) / 1e6  # Convert from raw to shares
    return balance

# Usage
balance = get_token_balance(
    wallet="0x7c2211103e7Fbb257Ac6fa59f972cfd8bc9D4795",
    token_id="12345678901234567890"
)
print(f"Position: {balance} shares")
Check USDC Balance
python
USDC_CONTRACT = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"

def get_usdc_balance(wallet: str) -> float:
    """Get USDC balance on Polygon"""
    # ERC-20 balanceOf(address)
    data = f"0x70a08231000000000000000000000000{wallet[2:].lower()}"

    r = requests.post(RPC_URL, json={
        "jsonrpc": "2.0",
        "method": "eth_call",
        "params": [{"to": USDC_CONTRACT, "data": data}, "latest"],
        "id": 1
    })

    result = r.json().get("result", "0x0")
    return int(result, 16) / 1e6  # USDC has 6 decimals

API Key Management

python
# Create new API key
creds = client.create_api_key(nonce=0)

# Derive existing API key (if you lost creds but have private key)
creds = client.derive_api_key(nonce=0)

# Create or derive (tries both)
creds = client.create_or_derive_api_creds(nonce=0)

# Get all your API keys
keys = client.get_api_keys()

# Delete current API key
client.delete_api_key()

# Readonly API keys (for monitoring only)
readonly = client.create_readonly_api_key()
client.get_readonly_api_keys()
client.delete_readonly_api_key(key="...")
client.validate_readonly_api_key(address="0x...", key="...")

Advanced Features

Order Heartbeat (Keep Orders Alive)
python
# Start heartbeat - if not sent within 10s, all orders cancelled
heartbeat_id = client.post_heartbeat(heartbeat_id=None)

# Continue sending heartbeats
while trading:
    client.post_heartbeat(heartbeat_id=heartbeat_id)
    time.sleep(5)
Order Scoring
python
# Check if order is scoring (earning rewards)
is_scoring = client.is_order_scoring(
    params=OrderScoringParams(order_id="...")
)

# Check multiple orders
scores = client.are_orders_scoring(
    params=OrdersScoringParams(order_ids=["ID1", "ID2"])
)
Notifications
python
notifications = client.get_notifications()
client.drop_notifications(params=DropNotificationParams(...))

Fee Structure

IMPORTANT: Most Polymarket markets have ZERO fees (0% maker, 0% taker).

15-min Crypto Markets (Exception)

Only 15-minute BTC/ETH/SOL/XRP price prediction markets have fees:

fee = shares × 0.25 × (price × (1 - price))²
Entry PriceFee % (per side)
0.50~1.56%
0.60 or 0.40~1.44%
0.70 or 0.30~1.10%
0.80 or 0.20~0.64%
0.90 or 0.10~0.20%

TAKER = crosses spread = PAYS fee MAKER = adds liquidity = NO fee + earns rebates

To be a maker: Post orders that don't immediately fill (inside the spread).


Decimal Precision Rules

Order SidePrice DecimalsSize Decimals
BUY24
SELL22

Min order size: $1 per side


Complete Trading Example

python
#!/usr/bin/env python3
"""
Production-ready Polymarket trading script
"""

import os
import time
import requests
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, ApiCreds, OrderType

# Initialize
client = ClobClient(
    "https://clob.polymarket.com",
    key=os.getenv("PRIVATE_KEY"),
    chain_id=137,
    funder=os.getenv("POLY_FUNDER_ADDRESS"),
    signature_type=2
)
client.set_api_creds(ApiCreds(
    api_key=os.getenv("POLY_API_KEY"),
    api_secret=os.getenv("POLY_API_SECRET"),
    api_passphrase=os.getenv("POLY_API_PASSPHRASE")
))

TOKEN_ID = "YOUR_TOKEN_ID"
WALLET = os.getenv("POLY_FUNDER_ADDRESS")
CTF = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"

def get_balance(token_id):
    """Get position size"""
    token_int = int(token_id)
    data = f"0x00fdd58e000000000000000000000000{WALLET[2:].lower()}{token_int:064x}"
    r = requests.post("https://polygon-rpc.com/", json={
        "jsonrpc": "2.0", "method": "eth_call",
        "params": [{"to": CTF, "data": data}, "latest"], "id": 1
    })
    return int(r.json().get("result", "0x0"), 16) / 1e6

def get_orderbook(token_id):
    """Get current bid/ask"""
    book = client.get_order_book(token_id)
    return {
        "best_bid": float(book.bids[0].price) if book.bids else 0,
        "best_ask": float(book.asks[0].price) if book.asks else 1
    }

# Check position
position = get_balance(TOKEN_ID)
print(f"Current position: {position} shares")

# Get market
book = get_orderbook(TOKEN_ID)
print(f"Bid: {book['best_bid']:.2f}, Ask: {book['best_ask']:.2f}")

# Place a buy order (maker - inside spread)
buy_price = book['best_bid'] + 0.01  # 1 cent above bid
if buy_price < book['best_ask']:  # Ensure we're maker
    result = client.create_and_post_order(OrderArgs(
        token_id=TOKEN_ID,
        price=buy_price,
        size=10.0,
        side="BUY"
    ))
    print(f"Buy order placed: {result}")

# Place a sell order (market sell via FOK)
if position > 0:
    result = client.create_and_post_order(OrderArgs(
        token_id=TOKEN_ID,
        price=0.01,  # Lowest price = immediate fill
        size=position,
        side="SELL"
    ))
    print(f"Sold position: {result}")

Error Handling

python
from py_clob_client.exceptions import PolyApiException

try:
    result = client.create_and_post_order(OrderArgs(...))
except PolyApiException as e:
    print(f"API Error: {e}")
except Exception as e:
    print(f"Error: {e}")

Common errors:

  • "insufficient balance" - Not enough USDC/tokens
  • "invalid price" - Price outside 0.01-0.99 or wrong decimals
  • "order too small" - Below minimum order size
  • "market closed" - Market not accepting orders

CLI Commands (/poly)

Access Polymarket trading directly from Claude Code:

Market Data
bash
/poly search <query>                     # Search markets
/poly market <condition-id>              # Market details
/poly book <token-id>                    # View orderbook
Trading
bash
/poly buy <token-id> <size> <price>      # Buy shares (limit)
/poly sell <token-id> <size> <price>     # Sell shares (limit)
/poly orders                             # Open orders
/poly cancel <order-id>                  # Cancel order
/poly cancel all                         # Cancel all orders
/poly trades [limit]                     # Recent trade history
/poly balance                            # USDC + positions
Advanced Orders
bash
/poly twap <buy|sell> <token> <total> <price> [slices] [interval-sec]
/poly bracket <token> <size> <tp> <sl>   # TP + SL bracket
/poly trigger buy <token> <size> <price> # Buy when price drops

Note: TWAP and bracket orders are persisted to the database and will automatically resume after restarts.

Auto-Redeem (Resolved Positions)
bash
/poly redeem                           # One-time redeem all resolved positions
/poly redeem start                     # Start auto-polling (default: every 60s)
/poly redeem stop                      # Stop auto-polling
/poly redeem status                    # Check auto-redeemer status
/poly redeem pending                   # List positions pending redemption
/poly redeem <conditionId> <tokenId>   # Redeem specific position

Env vars:

  • POLY_REDEEM_INTERVAL_MS - Polling interval in ms (default: 60000 = 1 minute)
Real-Time Fills (WebSocket)
bash
/poly fills                              # Connect fills WebSocket
/poly fills status                       # Show connection + recent fills
/poly fills stop                         # Disconnect fills WebSocket
/poly fills clear                        # Clear tracked fills
Order Heartbeat
bash
/poly heartbeat                          # Start heartbeat (keeps orders alive)
/poly heartbeat status                   # Check heartbeat status
/poly heartbeat stop                     # Stop heartbeat (orders cancelled in 10s)
Account & Settlements
bash
/poly settlements                        # View pending settlements from resolved markets
/poly allowance                          # Check USDC approval status
/poly orderbooks <token1> [token2] ...   # Batch fetch orderbooks

Complete ClobClient Method Reference

Health & Config (L0 - No Auth)
MethodParametersReturnsDescription
get_ok()-dictHealth check
get_server_time()-dictServer timestamp
get_address()-strYour signer address
get_collateral_address()-strUSDC contract
get_conditional_address()-strCTF contract
get_exchange_address(neg_risk)boolstrExchange contract
Market Data (L0 - No Auth)
MethodParametersReturnsDescription
get_midpoint(token_id)strdictMid price
get_midpoints(params)list[BookParams]dictMultiple mid prices
get_price(token_id, side)str, strdictBest price for side
get_prices(params)list[BookParams]dictMultiple prices
get_spread(token_id)strdictBid-ask spread
get_spreads(params)list[BookParams]dictMultiple spreads
get_order_book(token_id)strOrderBookSummaryFull orderbook
get_order_books(params)list[BookParams]listMultiple orderbooks
get_last_trade_price(token_id)strdictLast trade
get_last_trades_prices(params)list[BookParams]dictMultiple last trades
get_tick_size(token_id)strTickSize"0.1"/"0.01"/"0.001"/"0.0001"
get_neg_risk(token_id)strboolIs neg_risk market
get_fee_rate_bps(token_id)strintFee in basis points
Market Discovery (L0 - No Auth)
MethodParametersReturnsDescription
get_markets(next_cursor)strdictPaginated markets
get_simplified_markets(next_cursor)strdictSimplified markets
get_sampling_markets(next_cursor)strdictFeatured markets
get_market(condition_id)strdictSingle market
get_market_trades_events(condition_id)strdictTrade events
Order Creation (L1 - Needs Private Key)
MethodParametersReturnsDescription
create_order(order_args, options)OrderArgs, CreateOrderOptionsdictSign limit order
create_market_order(order_args, options)MarketOrderArgs, CreateOrderOptionsdictSign market order
calculate_market_price(token_id, side, amount, order_type)str, str, float, OrderTypefloatExpected fill price
Order Posting (L2 - Needs API Creds)
MethodParametersReturnsDescription
post_order(order, orderType, post_only)SignedOrder, OrderType, booldictPost single order
post_orders(args)list[PostOrdersArgs]dictPost batch orders
create_and_post_order(order_args, options)OrderArgs, PartialCreateOrderOptionsdictCreate + post (recommended)
Show full SKILL.md (403 more words)Show less
Order Cancellation (L2 - Needs API Creds)
MethodParametersReturnsDescription
cancel(order_id)strdictCancel one order
cancel_orders(order_ids)list[str]dictCancel multiple
cancel_all()-dictCancel ALL orders
cancel_market_orders(market, asset_id)str, strdictCancel by market
Order Queries (L2 - Needs API Creds)
MethodParametersReturnsDescription
get_orders(params, next_cursor)OpenOrderParams, strlistGet open orders
get_order(order_id)strdictGet specific order
get_trades(params, next_cursor)TradeParams, strlistTrade history
API Key Management (L2 - Needs API Creds)
MethodParametersReturnsDescription
create_api_key(nonce)intApiCredsCreate new key
derive_api_key(nonce)intApiCredsDerive existing key
create_or_derive_api_creds(nonce)intApiCredsCreate or derive
set_api_creds(creds)ApiCreds-Set credentials
get_api_keys()-dictList your keys
delete_api_key()-dictDelete current key
create_readonly_api_key()-ReadonlyApiKeyResponseReadonly key
get_readonly_api_keys()-list[str]List readonly keys
delete_readonly_api_key(key)strboolDelete readonly key
Balance & Allowance (L2 - Needs API Creds)
MethodParametersReturnsDescription
get_balance_allowance(params)BalanceAllowanceParamsdictCheck balance
update_balance_allowance(params)BalanceAllowanceParamsdictRefresh allowance
Advanced Features (L2 - Needs API Creds)
MethodParametersReturnsDescription
post_heartbeat(heartbeat_id)strdictKeep orders alive (10s timeout)
is_order_scoring(params)OrderScoringParamsdictCheck if earning rewards
are_orders_scoring(params)OrdersScoringParamsdictCheck multiple orders
get_notifications()-dictGet notifications
drop_notifications(params)DropNotificationParamsdictDelete notifications
get_closed_only_mode()-dictCheck closed-only status

Contract Addresses (Polygon Mainnet)

python
USDC = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"           # Collateral token
CTF  = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"           # Conditional tokens (ERC-1155)
EXCHANGE = "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E"       # Regular exchange
NEG_RISK = "0xC5d563A36AE78145C45a50134d48A1215220f80a"       # Neg risk exchange (crypto)

Quick Reference: Common Patterns

Check Position → Sell All
python
balance = get_token_balance(wallet, token_id)
if balance > 0:
    client.create_and_post_order(OrderArgs(
        token_id=token_id, price=0.01, size=balance, side="SELL"
    ))
Maker Entry (No Fees)
python
book = client.get_order_book(token_id)
best_bid = float(book.bids[0].price) if book.bids else 0
maker_price = best_bid + 0.01  # 1 cent above bid
signed = client.create_order(OrderArgs(token_id=token_id, price=maker_price, size=100, side="BUY"))
client.post_order(signed, orderType=OrderType.GTC, post_only=True)
Market Buy $50 Worth
python
signed = client.create_market_order(MarketOrderArgs(token_id=token_id, amount=50.0, side="BUY"))
client.post_order(signed, orderType=OrderType.FOK)
Cancel Everything
python
client.cancel_all()

WebSocket Channels (Real-Time Updates)

Polymarket provides WebSocket channels for real-time updates. No RPC needed - everything goes through CLOB.

WebSocket URLs
python
MARKET_WS = "wss://ws-subscriptions-clob.polymarket.com/ws/market"
USER_WS = "wss://ws-subscriptions-clob.polymarket.com/ws/user"
Market Channel (Public - No Auth)

Subscribe to orderbook updates, price changes, trades for any market.

python
import websocket
import json

def on_message(ws, message):
    data = json.loads(message)
    event_type = data.get("event_type")

    if event_type == "book":
        # Full orderbook snapshot (on subscribe + after trades)
        print(f"Book update: {data['bids']}, {data['asks']}")

    elif event_type == "price_change":
        # Order placed/cancelled affecting price level
        print(f"Price change: {data}")

    elif event_type == "last_trade_price":
        # Trade executed
        print(f"Trade: {data['price']} x {data['size']}")

    elif event_type == "tick_size_change":
        # Tick size changed (price went extreme)
        print(f"Tick size: {data['old_tick_size']} -> {data['new_tick_size']}")

def on_open(ws):
    # Subscribe to specific token
    ws.send(json.dumps({
        "type": "subscribe",
        "channel": "market",
        "assets_ids": [TOKEN_ID]  # List of token IDs
    }))

ws = websocket.WebSocketApp(
    "wss://ws-subscriptions-clob.polymarket.com/ws/market",
    on_message=on_message,
    on_open=on_open
)
ws.run_forever()
User Channel (Authenticated - For Fills)

Subscribe to YOUR order updates, fills, trades. This is how you get fill notifications.

python
import websocket
import json
import hmac
import hashlib
import time
import base64

API_KEY = os.getenv("POLY_API_KEY")
API_SECRET = os.getenv("POLY_API_SECRET")
API_PASSPHRASE = os.getenv("POLY_API_PASSPHRASE")

def get_auth_headers():
    """Generate HMAC auth for WebSocket"""
    timestamp = str(int(time.time()))
    message = f"GET\n{timestamp}\n/ws/user"
    signature = hmac.new(
        base64.b64decode(API_SECRET),
        message.encode(),
        hashlib.sha256
    ).digest()
    return {
        "POLY-ADDRESS": WALLET_ADDRESS,
        "POLY-SIGNATURE": base64.b64encode(signature).decode(),
        "POLY-TIMESTAMP": timestamp,
        "POLY-API-KEY": API_KEY,
        "POLY-PASSPHRASE": API_PASSPHRASE
    }

def on_message(ws, message):
    data = json.loads(message)
    event_type = data.get("event_type")

    if event_type == "trade":
        # YOUR FILL - order matched!
        status = data.get("status")  # MATCHED, MINED, CONFIRMED, FAILED
        print(f"FILL: {data['side']} {data['size']} @ {data['price']}")
        print(f"  Status: {status}")
        print(f"  Trade ID: {data['id']}")
        print(f"  Market: {data['market']}")

        if status == "CONFIRMED":
            print("  ✓ Trade confirmed on-chain!")
        elif status == "FAILED":
            print("  ✗ Trade failed - check logs")

    elif event_type == "order":
        order_type = data.get("type")  # PLACEMENT, UPDATE, CANCELLATION
        print(f"ORDER {order_type}: {data['side']} {data['original_size']} @ {data['price']}")
        print(f"  Filled: {data.get('size_matched', 0)}")

        if order_type == "CANCELLATION":
            print("  Order cancelled")

def on_open(ws):
    # Subscribe with auth
    ws.send(json.dumps({
        "type": "subscribe",
        "channel": "user",
        "auth": get_auth_headers(),
        # Optional: filter to specific market
        # "markets": [CONDITION_ID]
    }))

ws = websocket.WebSocketApp(
    "wss://ws-subscriptions-clob.polymarket.com/ws/user",
    on_message=on_message,
    on_open=on_open
)
ws.run_forever()
Message Types Summary

Market Channel:

EventTriggerKey Fields
bookSubscribe, trades affect bookbids, asks, timestamp
price_changeOrder placed/cancelledprice, size, side
last_trade_priceTrade executedprice, size, side
tick_size_changePrice extreme (>0.96 or <0.04)old_tick_size, new_tick_size

User Channel:

EventTriggerKey Fields
tradeYour order filledstatus, side, size, price, market
orderOrder placed/updated/cancelledtype (PLACEMENT/UPDATE/CANCELLATION), size_matched
Trade Status Flow
MATCHED → MINED → CONFIRMED (success)
                → RETRYING → CONFIRMED/FAILED
Keepalive

Send PING every 10 seconds to keep connection alive:

python
import threading

def send_ping():
    while True:
        ws.send(json.dumps({"type": "ping"}))
        time.sleep(10)

threading.Thread(target=send_ping, daemon=True).start()
Real-Time Data Client (Alternative)

Polymarket also provides @polymarket/real-time-data-client for TypeScript:

typescript
import { RealTimeDataClient } from "@polymarket/real-time-data-client";

const client = new RealTimeDataClient({
    onMessage: (msg) => console.log(msg),
    onConnect: (c) => {
        // Subscribe to user fills with auth
        c.subscribe({
            subscriptions: [{
                topic: "clob_user",
                type: "*",
                clob_auth: {
                    key: API_KEY,
                    secret: API_SECRET,
                    passphrase: API_PASSPHRASE
                }
            }]
        });
    }
});

client.connect();

No RPC Needed - CLOB Handles Everything

OperationMethod
Get positionsGET /data/positions?user={address} via Gamma API
Get balanceclient.get_balance_allowance()
Place ordersclient.create_and_post_order()
Get fillsUser WebSocket channel
Get pricesclient.get_order_book() or Market WebSocket
Cancel ordersclient.cancel()

The only time you might use RPC is to check on-chain token balances independently, but even that's available via Gamma API positions endpoint.

© alsk1992, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in src/skills/bundled/trading-polymarket of alsk1992/CloddsBot.

  • SKILL.md
  • index.ts

Open the folder on GitHubat commit c930628

Compare with similar skills

Trading Polymarket next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Trading Polymarket compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Trading Polymarket this skillalsk1992/CloddsBot3k—~8.3kAutomated safety check: PassMIT
Digital Oraclekomako-workshop/digital-oracle878—~5.9kAutomated safety check: PassMIT
Polymarket Tennislivetennisapi/livetennisapi-mcp152—~3kAutomated safety check: PassMIT
Catalyst ConfirmationSuperior-Trade/superior-skills215—~667Automated safety check: PassMIT
PolymarketAnil-matcha/awesome-muse-connectors1.3k—~790Automated safety check: PassMIT
Heytraders APILeoYeAI/openclaw-master-skills2.2k—~4.2kAutomated safety check: PassMIT

Similar skills

  • Digital Oracle

    komako-workshop/digital-oracle

    Answer prediction questions using market trading data, not opinions.

    878 GitHub stars~5.9k tokensUpdated 2 mo ago
    Business, Finance & HRAuto-check passed
  • Polymarket Tennis

    livetennisapi/livetennisapi-mcp

    Build observe-only Polymarket and Kalshi tennis market tooling on the polymarket-tennis Python package (MIT) plus the Live Tennis API free tier.

    152 GitHub stars~3k tokensUpdated 3 days ago
    Business, Finance & HRAuto-check passed
  • Catalyst Confirmation

    Superior-Trade/superior-skills

    A skill your agent uses when a Polymarket prediction-market thesis rests on an external event — CPI, Fed, elections, court rulings, ETF decisions — and needs market confirmation before committing.

    215 GitHub stars~667 tokensUpdated 1 mo ago
    Business, Finance & HRAuto-check passed
  • Polymarket

    Anil-matcha/awesome-muse-connectors

    Read-only Polymarket market data: events, markets, prices, order books.

    1.3k GitHub stars~790 tokensUpdated 5 days ago
    Business, Finance & HRAuto-check passed
  • Heytraders API

    LeoYeAI/openclaw-master-skills

    Trade crypto (Binance, Upbit, Hyperliquid, Lighter) and prediction markets (Polymarket).

    2.2k GitHub stars~4.2k tokensUpdated 2 mo ago
    Business, Finance & HRAuto-check passed
  • Trade Prediction Markets

    aAAaqwq/AGI-Super-Team

    Build and test Polymarket prediction market trading strategies for YES/NO token trading.

    105 GitHub starsUsed in 1 repo~4.7k tokens
    Business, Finance & HRAuto-check passed

More from alsk1992/CloddsBot

All 116 skills in this repo
  • Qmd

    alsk1992/CloddsBot

    Local hybrid search for markdown notes and docs. An agent skill from alsk1992/CloddsBot.

    3k GitHub starsUsed in 3 repos~1.2k tokens
    Auto-check passed
  • AI Strategy

    alsk1992/CloddsBot

    AI Strategy - natural language to trades. An agent skill from alsk1992/CloddsBot.

    3k GitHub stars~670 tokensUpdated 8 days ago
    Auto-check passed
  • Alerts

    alsk1992/CloddsBot

    Create and manage price alerts for prediction markets. An agent skill from alsk1992/CloddsBot.

    3k GitHub stars~460 tokensUpdated 8 days ago
    Auto-check passed
  • Analytics

    alsk1992/CloddsBot

    Performance attribution, trade analytics, and strategy optimization

    3k GitHub stars~1.6k tokensUpdated 8 days ago
    Auto-check passed
  • Arbitrage

    alsk1992/CloddsBot

    Automated cross-platform arbitrage detection and monitoring. An agent skill from alsk1992/CloddsBot.

    3k GitHub stars~1.7k tokensUpdated 8 days ago
    Auto-check passed
  • Auto Reply

    alsk1992/CloddsBot

    Automatic response rules, patterns, and scheduled messages. An agent skill from alsk1992/CloddsBot.

    3k GitHub stars~1.5k tokensUpdated 8 days ago
    Auto-check passed

Works with

Questions about Trading Polymarket

What does Trading Polymarket do?

Execute trades on Polymarket using pyclobclient - full API access for market data, orders, positions. Trading Polymarket is an agent skill from alsk1992/CloddsBot.

When should I use Trading Polymarket?

Trading Polymarket fits situations like: tasks that involve Trading and backtesting; tasks that involve Stock and market analysis.

How do I install Trading Polymarket in Claude Code?

Run `npx skills add alsk1992/CloddsBot --skill trading-polymarket -a claude-code`. Or copy the skill folder (src/skills/bundled/trading-polymarket in alsk1992/CloddsBot) into .claude/skills/trading-polymarket in your project. Claude Code loads it when a task matches its description.

How do I install Trading Polymarket in Codex?

Run `npx skills add alsk1992/CloddsBot --skill trading-polymarket -a codex`. Or copy the skill folder (src/skills/bundled/trading-polymarket in alsk1992/CloddsBot) into .agents/skills/trading-polymarket in your project. Codex loads it when a task matches its description.

Can I use Trading Polymarket in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add alsk1992/CloddsBot --skill trading-polymarket -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/trading-polymarket, .gemini/skills/trading-polymarket, .github/skills/trading-polymarket and .opencode/skills/trading-polymarket in your project.

What does Trading Polymarket need to run?

Going by SKILL.md and its folder, Trading Polymarket needs TypeScript for the scripts in its folder, the command-line tools its instructions call (pip) and credentials named POLY_API_KEY, POLY_API_SECRET, PRIVATE_KEY and API_KEY. Our summary lists: Python 3; Node.js; A credential in POLY_API_KEY; A credential in POLY_API_SECRET.

Does Trading Polymarket access the network?

SKILL.md names 3 domains. In commands or code: clob.polymarket.com, polygon-rpc.com and gamma-api.polymarket.com; the agent is likely to contact these when it follows the instructions. This is read from the text; nothing was executed.

Is Trading Polymarket safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Trading Polymarket use?

Trading Polymarket is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Trading Polymarket use?

About 8.3k tokens (SKILL.md is roughly 33k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Trading Polymarket?

Skills that share tags, products or a category with Trading Polymarket: Digital Oracle (komako-workshop/digital-oracle, 878 stars), Polymarket Tennis (livetennisapi/livetennisapi-mcp, 152 stars), Catalyst Confirmation (Superior-Trade/superior-skills, 215 stars) and Polymarket (Anil-matcha/awesome-muse-connectors, 1.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Trading Polymarket?

alsk1992 (a GitHub user) maintains it in alsk1992/CloddsBot, which has 2,951 GitHub stars. The repository holds 116 skills in this directory. The repository was last updated on October 2, 2026.

Source: alsk1992/CloddsBot on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.