6.1 KiB
Documentation Index
Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt Use this file to discover all available pages before exploring further.
Trading
CLOB order entry and management for market makers
Overview
Market makers primarily interact with Polymarket through the CLOB (Central Limit Order Book) API to post and manage limit orders.
Order Entry
Posting Limit Orders
Use the CLOB client to create and post limit orders:
import { ClobClient, Side, OrderType } from "@polymarket/clob-client";
const client = new ClobClient(
"https://clob.polymarket.com",
137,
wallet,
credentials,
signatureType,
funder
);
// Post a bid (buy order)
const bidOrder = await client.createAndPostOrder({
tokenID: "34097058504275310827233323421517291090691602969494795225921954353603704046623",
side: Side.BUY,
price: 0.48,
size: 1000,
orderType: OrderType.GTC
});
// Post an ask (sell order)
const askOrder = await client.createAndPostOrder({
tokenID: "34097058504275310827233323421517291090691602969494795225921954353603704046623",
side: Side.SELL,
price: 0.52,
size: 1000,
orderType: OrderType.GTC
});
See Create Order for full documentation.
Batch Orders
For efficiency, post multiple orders in a single request:
const orders = await Promise.all([
client.createOrder({ tokenID, side: Side.BUY, price: 0.48, size: 500 }),
client.createOrder({ tokenID, side: Side.BUY, price: 0.47, size: 500 }),
client.createOrder({ tokenID, side: Side.SELL, price: 0.52, size: 500 }),
client.createOrder({ tokenID, side: Side.SELL, price: 0.53, size: 500 })
]);
const response = await client.postOrders(
orders.map(order => ({ order, orderType: OrderType.GTC }))
);
See Post Orders Batch for details.
Order Types
| Type | Behavior | MM Use Case |
|---|---|---|
| GTC (Good Till Cancelled) | Rests on book until filled or cancelled | Default for passive quoting |
| GTD (Good Till Date) | Auto-expires at specified time | Auto-expire before events |
| FOK (Fill or Kill) | Fill entirely immediately or cancel | Aggressive rebalancing (all or nothing) |
| FAK (Fill and Kill) | Fill available immediately, cancel rest | Partial rebalancing acceptable |
When to Use Each
For passive market making (maker orders):
- GTC - Standard quotes that sit on the book
- GTD - Time-limited quotes (e.g., expire before market close)
For rebalancing (taker orders):
- FOK - When you need exact size or nothing
- FAK - When partial fills are acceptable
// GTD example: expire in 1 hour
const expiringOrder = await client.createOrder({
tokenID,
side: Side.BUY,
price: 0.50,
size: 1000,
orderType: OrderType.GTD,
expiration: Math.floor(Date.now() / 1000) + 3600 // 1 hour from now
});
Order Management
Cancel Orders
Cancel individual orders or all orders:
// Cancel single order
await client.cancelOrder(orderId);
// Cancel multiple orders in a single calls
await client.cancelOrders(orderIds: string[]);
// Cancel all orders for a market
await client.cancelMarketOrders(conditionId);
// Cancel all orders
await client.cancelAll();
See Cancel Orders for full documentation.
Get Active Orders
Monitor your open orders:
// Get active order
const order = await client.getOrder(orderId);
// Get active orders optionally filtered
const orders = await client.getOpenOrders({
id?: string; // Order ID (hash)
market?: string; // Market condition ID
asset_id?: string; // Token ID
});
See Get Active Orders for details.
Best Practices
Quote Management
- Two-sided quoting - Post both bids and asks to earn maximum liquidity rewards
- Monitor inventory - Skew quotes based on your position
- Cancel stale quotes - Remove orders when market conditions change
- Use GTD for events - Auto-expire quotes before known events
Latency Optimization
- Batch orders - Use
postOrders()instead of multiplecreateAndPostOrder()calls - WebSocket for data - Use WebSocket feeds instead of polling REST endpoints
Risk Management
- Size limits - Check token balances before quoting; don't exceed inventory
- Price guards - Validate against book midpoint; reject outlier prices
- Kill switch - Use
cancelAll()on error or position breach - Monitor fills - Subscribe to WebSocket user channel for real-time fill updates
Tick Sizes
Markets have different minimum price increments:
const tickSize = await client.getTickSize(tokenID);
// Returns: "0.1" | "0.01" | "0.001" | "0.0001"
Ensure your prices conform to the market's tick size.
Fee Structure
| Role | Fee |
|---|---|
| Maker | 0 bps |
| Taker | 0 bps |
Current fees are 0% for both makers and takers. See CLOB Introduction for fee calculation details.