Orders

Cancel Order

This will cancel an order. If the order is already canceled, the message will succeed but have no effect.

<div class="p-4 text-sm section-icon section-info rounded-sm" role="alert"> <div class="flex"> <svg view-box="0 0 24 24" > <path fill-rule="evenodd" clip-rule="evenodd" d="M4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12ZM12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM11 17V11H13V17H11ZM11 9V7H13V9H11Z" /> </svg> Enabled for perpetuals accounts from July 10th, 0100hrs ET onwards. </div> </div>

Roles

The API key you use to access this endpoint must have the Trader role assigned. See Roles for more information.

The OAuth scope must have orders:create assigned to access this endpoint. See OAuth Scopes for more information.

All Cancellation Reasons

Under unique circumstances, orders may be automatically cancelled by the exchange. These scenarios are detailed in the table below:

Cancel ReasonDescription
MakerOrCancelWouldTakeOccurs when the "maker-or-cancel" execution option is included in the order request and any part of the requested order could be filled immediately.
ExceedsPriceLimitsOccurs when there is not sufficient liquidity on the order book to support the entered trade. Orders will be automatically cancelled when liquidity conditions are such that the order would move price +/- 5%.
SelfCrossPreventedOccurs when a user enters a bid that is higher than that user's lowest open ask or enters an ask that is lower than their highest open bid on the same pair.
ImmediateOrCancelWouldPostOccurs when the "immediate-or-cancel" execution option is included in the order request and the requested order cannot be fully filled immediately. This type of cancellation will only cancel the unfulfilled part of any impacted order.
FillOrKillWouldNotFillOccurs when the "fill-or-kill" execution option is included in the new order request and the entire order cannot be filled immediately.<br><br>Unlike "immediate-or-cancel" orders, this execution option will result in the entire order being cancelled rather than just the unfulfilled portion.
RequestedCancelled via user request to /v1/order/cancel endpoint.
MarketClosedOccurs when an order is placed for a trading pair that is currently closed.
TradingClosedOccurs when an order is placed while the exchange is closed for trading.
post/v1/order/cancel

Request

  • Base URL
    https://api.gemini.com
  • URL
    https://api.gemini.com/v1/order/cancel
  • Auth
    API key in header X-GEMINI-APIKEY and API key in header X-GEMINI-SIGNATURE and API key in header X-GEMINI-PAYLOAD

Headers

X-GEMINI-APIKEYstring required

Your API key

X-GEMINI-SIGNATUREstring required

HEX-encoded HMAC-SHA384 of payload signed with API secret

X-GEMINI-PAYLOADstring required

Base64-encoded JSON payload

Content-Typestring
Content-Lengthstring
Cache-Controlstring

Request body

requeststring required

The literal string "/v1/order/cancel"

order_idinteger required

The order ID given by /order/new

accountstring

Required for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to cancel the order. Only available for exchange accounts.

Example request

{
  "request": "/v1/order/cancel",
  "nonce": "1495127793000",
  "order_id": 106817811,
  "account": "primary"
}

Response

Response will be the fields included in Order Status. If the order was already canceled, then the request will have no effect and the status will be returned. Note the is_cancelled node will have a value of 'true'

order_idstring integer
idstring integer
symbolstring
exchangestring
avg_execution_pricestring double
side'buy' | 'sell'
type'exchange limit' | 'exchange stop limit' | 'exchange market'
is_liveboolean
is_cancelledboolean
is_hiddenboolean
was_forcedboolean
executed_amountstring double
remaining_amountstring double
reason'MakerOrCancelWouldTake' | 'ExceedsPriceLimits' | 'SelfCrossPrevented' | 'ImmediateOrCancelWouldPost' | 'FillOrKillWouldNotFill' | 'Requested' | 'MarketClosed' | 'TradingClosed'
optionsstring[]
pricestring double
original_amountstring double

Example response

{
  "timestamp": "1495127793000",
  "timestampms": "1495127793000"
}

Changes

No recorded changes to this operation across all 1 revision of this API.