Cancels the specified order
To cancel an order, construct a payload using the "oc" (order cancel) abbreviation. The order details need to include either the Internal Order ID or the Client Order ID and Client Order ID Date (YYYY-MM-DD format). Please look to the sidebar for examples.
When you cancel an order, you will receive a message of the appropriated type on the "account info" channel. Example responses are included in the sidebar. Please look to the Orders and Notifications pages for further information.
Order inputs require you to run the authentication code along with additional code for the input. The authentication code can be found on our Authenticated Channels and the additional code for inputs can be found on the Websocket Inputs page.
// Cancel order by internal order Id
[
0,
"oc",
null,
{
"id": ID
}
]
// Cancel order using client order Id and order creation date
[
0,
"oc",
null,
{
"cid": CID,
"cid_date": CID_DATE
}
]// When the cancellation request is submitted you will receive an 'n' (notification) event as confirmation. If the cancellation is successful, you will also receive an 'oc' (order cancelled) event. Both events are sent through CHANNEL_ID = 0.
[
0, // CHANNEL_ID
"n", // EVENT
[
1575291219660, // MTS
"oc-req", // TYPE
null, // MESSAGE_ID
null, // _PLACEHOLDER
[
1185815100, // ID
null, // GID
1575289350475, // CID
"tETHUSD", // SYMBOL
1575289351944, // MTS_CREATE
1575289447644, // MTS_UPDATE
-3, // AMOUNT
-3, // AMOUNT_ORIG
"LIMIT", // ORDER_TYPE
"LIMIT", // TYPE_PREV
null, // MTS_TIF
null, // _PLACEHOLDER
0, // FLAGS
"ACTIVE", // STATUS
null, // _PLACEHOLDER
null, // _PLACEHOLDER
240, // PRICE
0, // PRICE_AVG
0, // PRICE_TRAILING
0, // PRICE_AUX_LIMIT
null, // _PLACEHOLDER
null, // _PLACEHOLDER
null, // _PLACEHOLDER
0, // NOTIFY
0, // HIDDEN
null, // PLACED_ID
null, // _PLACEHOLDER
null, // _PLACEHOLDER
"API>BFX", // ROUTING
null, // _PLACEHOLDER
null, // _PLACEHOLDER
null // META
],
null, // CODE
"SUCCESS", // STATUS
"Submitted for cancellation; waiting for confirmation (ID: 1185815100)." // TEXT
]
]
[
0, // CHANNEL_ID
"oc", // EVENT
[
1185815100, // ID
null, // GID
1575289350475, // CID
"tETHUSD", // SYMBOL
1575289351944, // MTS_CREATE
1575291219663, // MTS_UPDATE
-3, // AMOUNT
-3, // AMOUNT_ORIG
"LIMIT", // ORDER_TYPE
"LIMIT", // TYPE_PREV
null, // MTS_TIF
null, // _PLACEHOLDER
0, // FLAGS
"CANCELED", // STATUS
null, // _PLACEHOLDER
null, // _PLACEHOLDER
240, // PRICE
0, // PRICE_AVG
0, // PRICE_TRAILING
0, // PRICE_AUX_LIMIT
null, // _PLACEHOLDER
null, // _PLACEHOLDER
null, // _PLACEHOLDER
0, // NOTIFY
0, // HIDDEN
null, // PLACED_ID
null, // _PLACEHOLDER
null, // _PLACEHOLDER
"API>BFX", // ROUTING
null, // _PLACEHOLDER
null, // _PLACEHOLDER
null // META
]
]
Request fields
| Name | Type | Description |
|---|---|---|
| id | Int | Internal Order ID |
| cid | Int | Client Order ID |
| cid_date | String | Client Order ID Date |
Cancel order notification data
| Index | Field | Type | Description |
|---|---|---|---|
| [0] | CHANNEL_ID | Int | ID of the channel. (0 for account info messages) |
| [1] | EVENT | String | Type of event ('n' for notification) |
| [2] | NOTIFICATION_ARRAY | Array | Notification array |
Notification array data
| Index | Field | Type | Description |
|---|---|---|---|
| [0] | MTS | Int | Millisecond Time Stamp of the update |
| [1] | TYPE | String | Purpose of notification ('oc-req') |
| [2] | MESSAGE_ID | Int | Unique ID of the message |
| [3] | _PLACEHOLDER | ||
| [4] | ORDER_ARRAY | Array | Order data |
| [5] | CODE | Null or integer | Work in progress |
| [6] | STATUS | String | Status of the notification; it may vary over time (SUCCESS, ERROR, FAILURE, ...) |
| [7] | TEXT | String | Text of the notification |
"oc" event data
| Index | Field | Type | Description |
|---|---|---|---|
| [0] | CHANNEL_ID | Int | ID of the channel. (0 for account info messages) |
| [1] | TYPE | String | Type of event ('oc' for order cancelled) |
| [2] | ORDER_ARRAY | Array | Order data |
Order Array data
| Index | Field | Type | Description |
|---|---|---|---|
| [0] | ID | Int | Order ID |
| [1] | GID | Int | Group ID |
| [2] | CID | Int | Client Order ID |
| [3] | SYMBOL | String | Pair (tBTCUSD, …) |
| [4] | MTS_CREATE | Int | Millisecond timestamp of creation |
| [5] | MTS_UPDATE | Int | Millisecond timestamp of update |
| [6] | AMOUNT | Float | Positive means buy, negative means sell. |
| [7] | AMOUNT_ORIG | Float | Original amount |
| [8] | ORDER_TYPE | String | The type of the order: LIMIT, MARKET, STOP, STOP LIMIT, TRAILING STOP, FOK, IOC For exchange orders: EXCHANGE MARKET, EXCHANGE LIMIT, EXCHANGE STOP, EXCHANGE STOP LIMIT, EXCHANGE TRAILING STOP, EXCHANGE FOK, EXCHANGE IOC. |
| [9] | TYPE_PREV | String | Previous order type |
| [10] | MTS_TIF | Int | Millisecond timestamp of Time-In-Force: automatic order cancellation |
[ . . . ] | |||
| [12] | FLAGS | Int | See https://docs.bitfinex.com/v2/docs/flag-values |
| [13] | ORDER_STATUS | String | Order Status: ACTIVE, EXECUTED @ PRICE(AMOUNT) e.g. "EXECUTED @ 107.6(-0.2)", PARTIALLY FILLED @ PRICE(AMOUNT), INSUFFICIENT MARGIN was: PARTIALLY FILLED @ PRICE(AMOUNT), CANCELED, CANCELED was: PARTIALLY FILLED @ PRICE(AMOUNT), RSN_DUST (amount is less than 0.00000001), RSN_PAUSE (trading is paused due to rebase events on AMPL or funding settlement on derivatives) |
[ . . . ] | |||
| [16] | PRICE | Float | Price |
| [17] | PRICE_AVG | Float | Average price |
| [18] | PRICE_TRAILING | Float | The trailing price |
| [19] | PRICE_AUX_LIMIT | Float | Auxiliary Limit price (for STOP LIMIT) |
[ . . . ] | |||
| [23] | NOTIFY | Int | 0 if false, 1 if true |
| [24] | HIDDEN | Int | 1 if Hidden, 0 if not hidden |
| [25] | PLACED_ID | Int | If another order caused this order to be placed (OCO) this will be that other order's ID |
[ . . . ] | |||
| [28] | ROUTING | String | Indicates origin of action: BFX, ETHFX, API>BFX, API>ETHFX |
[ . . . ] | |||
| [31] | META | Json string | Additional meta information about the order (e.g., $F7 = IS_POST_ONLY (0 if false, 1 if true), $F33 = Leverage (int)) |
