PlaceOrder · write key · write rate class
Places one order: open a position, add to one, close one, or protect one with a take-profit or stop-loss.
Body
Every price, trigger, take-profit and stop-loss must be a multiple of the market’s
tickSize from ListMarkets.
Response
clientOrderId answers all four, omitting them until that fill’s trades are recorded.
Retrying safely
- Any RFC 9562 UUID version is accepted, in the 36-character hyphenated form, and will stay accepted, so a version 8 UUID that packs your own id works.
- The same
clientOrderIdwith a different order answersfailed_precondition, except a retry that only asks for a larger quantity, which can still answer the first order, withacceptedQuantitywhen the stored quantity is smaller than the retry asked for. maxSlippageBpsis not compared: a retry answers the first order’s execution whatever cap it carries, so a tighter cap on a retry neither reprices nor refuses a fill that already happened. Repeat the first attempt’s parameters.- A
clientOrderIdthat already names an order on another account answersalready_exists.
Order types
MARKET
- Fills against the book. A fill that would move past
maxSlippageBpsrefuses the whole order withfailed_preconditionbefore any of it executes. maxSlippageBpsis accepted on a MARKET order that opens or adds to a position and on a reduce-only MARKET, and refused on every other type, so an exit that rests or waits for a trigger is never price-capped.- In the default one-way position mode, a MARKET order without
reduceOnly,takeProfitPriceorstopLossPrice, opposite an open position that is not a pair leg, no larger than it and naming no otherpositionId, is placed as that position’s reduce-only exit: it fills the visible depth instead of being refused for its size (maxSlippageBpsstill applies),acceptedQuantitygives the size filled, and it is listed withreduceOnlyand thepositionId. - If the position or the mode cannot be read at that moment, the order is placed as an ordinary opening order instead, and if the position has closed meanwhile it opens one on the other side. For an exit that can never open a position, send
reduceOnly: truewith thepositionId, or call ClosePosition.
LIMIT
- A LIMIT that crosses the book fills at once, as taker, at the book’s average price.
- A crossing LIMIT without
reduceOnly, even one opposite a position, is refused withfailed_preconditionwhen the visible depth is short of its size, or when that average is worse than its limit price by more than a tolerance, 10 basis points today. - A LIMIT without
reduceOnlyis sized at its limit price, however far through the book: quantity ×pricemust fitmaxPositionSize, and attached exits must sit on the right side ofprice, or it answersinvalid_argument. - A LIMIT priced not to cross usually rests, but the market can move first, so it can still fill as taker. Only
postOnlywould guarantee a maker order, and PlaceOrder does not accept it.
Triggered orders
- STOP_MARKET, TAKE_PROFIT and STOP_LOSS fire when the mark price or the best bid or offer on their executing side reaches
triggerPrice, whichever comes first. - A
triggerPricethat the mark price or that best bid or offer has already reached answersinvalid_argument, and the message names the price it had to be beyond. A stop refused this way means its level is already hit, so close at market instead of retrying the stop. - A take-profit or stop-loss on an open position is TAKE_PROFIT or STOP_LOSS with its
positionIdandtriggerPrice. - Exits attached with
takeProfitPriceandstopLossPriceappear only as fields on the opening order until it fills, then become separate TAKE_PROFIT and STOP_LOSS orders with their own ids. Find them in ListOpenOrders bypositionIdandtype.
Markets with a fill cap
On markets whose fills are capped near the mark price, today BRENTOIL, CL, GOLD, SILVER, SP500 and XYZ100, size the book cannot fill within the cap fills at the cap price, so depth neither refuses nor cuts a LIMIT there. While the cap cannot be set, as when the mark price is stale or far from the book, a MARKET or crossing LIMIT withoutreduceOnly there is refused with failed_precondition and can be retried a moment later; a reduce-only one fills the visible depth, and a triggered STOP_MARKET fills uncapped.
Exits
- To close or reduce a position, send
reduceOnly: truewith itspositionId, the position’ssymbol, the opposite side and the quantity to close. A take-profit or stop-loss names the same symbol and side. - A reduce-only MARKET larger than the position is trimmed to it, so it closes the whole position unless book liquidity sizes it down. ClosePosition does the same without a quantity, on the exit budget.
- Reduce-only LIMITs, take-profits and stop-losses each form their own ladder: one kind together covers at most the position’s size, and the one closest to the market fills first.
- A new exit closer to the market than one of its kind shrinks or cancels the farther one, with no error. One lying wholly beyond what its ladder covers answers
failed_precondition, kindREDUCE_ONLY_NO_CAPACITY. A reduce-only STOP_MARKET never uses ladder capacity. - An exit listed with
closePosition, as the one an entry attaches withstopLossPriceortakeProfitPricecan be, covers the whole position and sits outside its ladder. A sized exit of the same kind placed farther from the market than it succeeds, and moves that protection: the whole-position order is cancelled and placed again under a neworderId, sized at the position less the sized exits, and your new order becomes the whole-position exit, listed withclosePosition. On a 1 BTC long with an attached stop at 45,000, a 0.3 BTC stop at 44,000 leaves 0.7 BTC stopped at 45,000 and makes 44,000 the stop for whatever remains. When your new exit and the other sized exits already cover the whole position, nothing replaces the whole-position order: a 1 BTC stop at 44,000 on that long leaves it stopped at 44,000 only, so a full-size backup stop placed farther out removes the nearer one. Read ListOpenOrders after placing an exit to see what now protects the position. - When the position closes, its reduce-only orders are cancelled, and a partial close shrinks any that would exceed what remains.
- An exit on a position that has already closed, as when two closes race, answers
failed_precondition, kindPOSITION_ALREADY_CLOSED: treat the close as done. - An exit on a leg of a pair trade answers
failed_precondition: a pair closes as a pair, in the app or through CloseAllPositions.
Limits
An account is limited to 300 resting orders that open or add to a position, untriggered stops included. One more answersfailed_precondition, kind TOO_MANY_OPEN_ORDERS, until one fills or is cancelled; reduce-only orders, take-profits and stop-losses do not count.
An account may separately be limited to 300 resting reduce-only orders, take-profits and stop-losses.
One more answers the same code and kind, and so does an order that attaches takeProfitPrice or stopLossPrice. The message tells the two limits apart, beginning too many open orders or too many open exit orders, and says how many to cancel.
The exits an entry attaches are still created when it fills, so an account can hold more than 300, and a reduce-only MARKET is never refused for either limit, so a position can always be closed.
An order may also be refused with invalid_argument when it is worth less than $10, on every market.
A LIMIT is valued at its price, a STOP_MARKET at its triggerPrice and a MARKET at the price it would fill at.
Reduce-only orders, take-profits, stop-losses and a MARKET placed as a position’s reduce-only exit are never refused for it. A LIMIT or STOP_MARKET without reduceOnly is measured even when it would only reduce a position, so send a small exit with reduceOnly: true.

