This guide demonstrates how to create basic limit orders using the CLOB Client SDK. You’ll learn how to place buy and sell orders with different time-in-force options.
The most basic order creation involves specifying a token ID, price, side, and size:
const YES_TOKEN = "71321045679252212594626385532706912750332728571942532289631379312455583992563";// Create a buy order for 100 shares at $0.50 eachconst buyOrder = await clobClient.createOrder({ tokenID: YES_TOKEN, price: 0.50, side: Side.BUY, size: 100,});console.log("Created order:", buyOrder);// Post the order to the exchangeconst result = await clobClient.postOrder(buyOrder, OrderType.GTC);console.log("Order posted:", result);
For convenience, use createAndPostOrder() to create and post in one step:
const YES_TOKEN = "71321045679252212594626385532706912750332728571942532289631379312455583992563";const result = await clobClient.createAndPostOrder( { tokenID: YES_TOKEN, price: 0.50, side: Side.BUY, size: 100, }, { tickSize: "0.01", negRisk: false }, OrderType.GTC);console.log("Order created and posted:", result);
The tickSize must match the market’s tick size. Common values are "0.1", "0.01", "0.001", or "0.0001". Check the market details to determine the correct tick size.
Post-only orders are guaranteed not to match immediately. They’re only supported for GTC and GTD orders:
const order = await clobClient.createOrder({ tokenID: YES_TOKEN, price: 0.50, side: Side.BUY, size: 100,});// Post-only is the 4th parameter (postOnly = true)const result = await clobClient.postOrder( order, OrderType.GTC, false, // deferExec true // postOnly);console.log("Post-only order:", result);
Post-only orders will be rejected if they would immediately match with existing orders. This is useful for market makers who want to ensure they’re providing liquidity.