## GTC Order
#
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY

## Create and sign a limit order buying 100 YES tokens for 0.50c each
order_args = OrderArgs(
    price=0.50,
    size=100.0,
    side=BUY,
    token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
)
signed_order = client.create_order(order_args)

## GTC Order
resp = client.post_order(signed_order, OrderType.GTC)
print(resp)
## GTD Order
#
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY

## Create and sign a limit order buying 100 YES tokens for 0.50c each
order_args = OrderArgs(
    price=0.50,
    size=100.0,
    side=BUY,
    token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
    # There is a 1 minute of security threshold for the expiration field.
    # If we need the order to expire in 30 seconds the correct expiration value is:
    # now + 1 miute + 30 seconds
    expiration="100000000000"
)
signed_order = client.create_order(order_args)

## GTD Order
resp = client.post_order(signed_order, OrderType.GTD)
print(resp)
## FOK BUY Order
#
from py_clob_client.clob_types import MarketOrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY

## Create and sign a market BUY order for $100
order_args = MarketOrderArgs(
    token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
    amount=100.0, # $$$
    side=BUY,
)
signed_order = client.create_market_order(order_args)

## FOK Order
resp = client.post_order(signed_order, OrderType.FOK)
print(resp)
## FOK SELL Order
#
from py_clob_client.clob_types import MarketOrderArgs, OrderType
from py_clob_client.order_builder.constants import SELL

## Create and sign a market BUY order for 100 shares
order_args = MarketOrderArgs(
    token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
    amount=100.0, # shares
    side=SELL,
)
signed_order = client.create_market_order(order_args)

## FOK Order
resp = client.post_order(signed_order, OrderType.FOK)
print(resp)

Create and Place an Order

This endpoint requires a L2 Header

Create and place an order using the Polymarket CLOB API clients. All orders are represented as “limit” orders, but “market” orders are also supported. To place a market order, simply ensure your price is marketable against current resting limit orders, which are executed on input at the best price. Thus to:

HTTP REQUEST

POST /<clob-endpoint>/order

Request Payload Parameters

NameRequiredTypeDescription
orderyesOrdersigned object
owneryesstringapi key of order owner
orderTypeyesstringorder type (“FOK”, “GTC”, “GTD”)

An order object is the form:

NameRequiredTypeDescription
saltyesintegerrandom salt used to create unique order
makeryesstringmaker address (funder)
signeryesstringsigning address
takeryesstringtaker address (operator)
tokenIdyesstringERC1155 token ID of conditional token being traded
makerAmountyesstringmaximum amount maker is willing to spend
takerAmountyesstringminimum amount taker will pay the maker in return
expirationyesstringunix expiration timestamp
nonceyesstringmaker’s exchange nonce of the order is associated
feeRateBpsyesstringfee rate basis points as required by the operator
sideyesstringbuy or sell enum index
signatureTypeyesintegersignature type enum index
signatureyesstringhex encoded signature

Order types

  • FOK: A Fill-Or-Kill order is an market order to buy (in dollars) or sell (in shares) shares that must be executed immediately in its entirety; otherwise, the entire order will be cancelled.
  • GTC: A Good-Til-Cancelled order is a limit order that is active until it is fulfilled or cancelled.
  • GTD: A Good-Til-Date order is a type of order that is active until its specified date (UTC seconds timestamp), unless it has already been fulfilled or cancelled. There is a security threshold of one minute. If the order needs to expire in 30 seconds the correct expiration value is: now * 1 mute + 30 seconds

Response Format

NameTypeDescription
successbooleanboolean indicating if server-side err (success = false) -> server-side error
errorMsgstringerror message in case of unsuccessful placement (in case success = false, e.g. client-side error, the reason is in errorMsg)
orderIdstringid of order
orderHashesstring[]hash of settlement transaction order was marketable and triggered a match

Insert Error Messages

If the errorMsg field of the response object from placement is not an empty string, the order was not able to be immediately placed. This might be because of a delay or because of a failure. If the success is not true, then there was an issue placing the order. The following errorMessages are possible:

Error

ErrorSuccessMessageDescription
INVALID_ORDER_MIN_TICK_SIZEyesorder is invalid. Price breaks minimum tick size rulesorder price isn’t accurate to correct tick sizing
INVALID_ORDER_MIN_SIZEyesorder is invalid. Size lower than the minimumorder size must meet min size threshold requirement
INVALID_ORDER_DUPLICATEDyesorder is invalid. Duplicated. Same order has already been placed, can’t be placed again
INVALID_ORDER_NOT_ENOUGH_BALANCEyesnot enough balance / allowancefunder address doesn’t have sufficient balance or allowance for order
INVALID_ORDER_EXPIRATIONyesinvalid expirationexpiration field expresses a time before now
INVALID_ORDER_ERRORyescould not insert ordersystem error while inserting order
EXECUTION_ERRORyescould not run the executionsystem error while attempting to execute trade
ORDER_DELAYEDnoorder match delayed due to market conditionsorder placement delayed
DELAYING_ORDER_ERRORyeserror delaying the ordersystem error while delaying order
FOK_ORDER_NOT_FILLED_ERRORyesorder couldn’t be fully filled, FOK orders are fully filled/killedFOK order not fully filled so can’t be placed
MARKET_NOT_READYnothe market is not yet ready to process new orderssystem not accepting orders for market yet

Insert Statuses

When placing an order, a status field is included. The status field provides additional information regarding the order’s state as a result of the placement. Possible values include:

Status

StatusDescription
matchedorder placed and live
delayedorder marketable, but subject to matching delay
unmatchedorder marketable, but failure delaying, placement successful
## GTC Order
#
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY

## Create and sign a limit order buying 100 YES tokens for 0.50c each
order_args = OrderArgs(
    price=0.50,
    size=100.0,
    side=BUY,
    token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
)
signed_order = client.create_order(order_args)

## GTC Order
resp = client.post_order(signed_order, OrderType.GTC)
print(resp)
## GTD Order
#
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY

## Create and sign a limit order buying 100 YES tokens for 0.50c each
order_args = OrderArgs(
    price=0.50,
    size=100.0,
    side=BUY,
    token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
    # There is a 1 minute of security threshold for the expiration field.
    # If we need the order to expire in 30 seconds the correct expiration value is:
    # now + 1 miute + 30 seconds
    expiration="100000000000"
)
signed_order = client.create_order(order_args)

## GTD Order
resp = client.post_order(signed_order, OrderType.GTD)
print(resp)
## FOK BUY Order
#
from py_clob_client.clob_types import MarketOrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY

## Create and sign a market BUY order for $100
order_args = MarketOrderArgs(
    token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
    amount=100.0, # $$$
    side=BUY,
)
signed_order = client.create_market_order(order_args)

## FOK Order
resp = client.post_order(signed_order, OrderType.FOK)
print(resp)
## FOK SELL Order
#
from py_clob_client.clob_types import MarketOrderArgs, OrderType
from py_clob_client.order_builder.constants import SELL

## Create and sign a market BUY order for 100 shares
order_args = MarketOrderArgs(
    token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
    amount=100.0, # shares
    side=SELL,
)
signed_order = client.create_market_order(order_args)

## FOK Order
resp = client.post_order(signed_order, OrderType.FOK)
print(resp)