Messages
The baseline specification for this API is FIX 4.2. There are additional tags from later versions of FIX, and custom tags in the high number range as allowed by the standard.
A standard header must be present at the start of every message in both directions.
Tag | Name | Description |
---|---|---|
8 | BeginString | Must be FIX.4.2 |
49 | SenderCompID | Client API key (on messages from the client) |
56 | TargetCompID | Must be Coinbase (on messages from the client) |
New orders can only be placed when the number of open orders is below 500 for that given product.
Logon (A)
Sent by the client to initiate a session and by the server as an acknowledgement. Only one session may exist per connection; sending a Logon message within an established session is an error.
Tag | Name | Description |
---|---|---|
98 | EncryptMethod | Must be 0 (None) |
108 | HeartBtInt | Must be β€ 30 (secs). Values greater are capped at 30 . Server sends Test Request if client messages are not received in approximately (HeartBtInt x 1.5) seconds. Server terminates session if client messages are not received in approximately (HeartBtInt x 2 seconds). |
554 | Password | Client API passphrase |
96 | RawData | Client message signature (see below) |
8013 | CancelOrdersOnDisconnect | S : Batch cancel all open orders placed during session; Y : Batch cancel all open orders for the current profile. The latter is more performant and recommended. |
9406 | DropCopyFlag | If set to Y , execution reports are generated for all user orders (defaults to Y ). |
The Logon message sent by the client must be signed for security. The signing method is described in Signing a Message. The prehash string is the following fields joined by the FIX field separator (ASCII code 1):
SendingTime, MsgType, MsgSeqNum, SenderCompID, TargetCompID, Password
.
There is no trailing separator. The RawData
field should be a base64 encoding of the HMAC signature.
// create a new Logon message
var logon = new Msgs.Logon();
logon.SendingTime = new Date();
logon.HeartBtInt = 30;
logon.EncryptMethod = 0;
logon.passphrase = '...';
var presign = [
logon.SendingTime,
logon.MsgType,
session.outgoing_seq_num,
session.sender_comp_id,
session.target_comp_id,
passphrase
].join('\x01');
// add the presign string to the RawData field of the Logon message
logon.RawData = sign(presign, secret);
// send the logon message to the server
session.send(logon);
function sign(what, secret) {
var key = Buffer(secret, 'base64');
var hmac = crypto.createHmac('sha256', key);
return hmac.update(what).digest('base64');
}
To establish multiple FIX connections, generate a new API key for each one. The maximum is 7 connections per profile. Do not use a single API key for multiple connections at the same time.
The value of
SendingTime
must be within 5 minutes of server time in UTC.
Logout (5)
Sent by either side to initiate session termination. The side which receives this message first should reply with the same message type to confirm session termination.
Do not close a connection without logging out of the session first or it triggers an error.
New Order Single (D)
Sent by the client to enter an order. Each profile can place a maximum of 500 open orders on a product. Once reached, the profile cannot place any new orders until the total number of open orders is below 500.
Tag | Name | Description |
---|---|---|
11 | ClOrdID | UUID selected by client to identify the order |
55 | Symbol | Required symbol to identify the new order, e.g., BTC-USD |
54 | Side | Must be 1 to buy or 2 to sell |
44 | Price | Limit price (e.g., in USD) (Limit order only) |
38 | OrderQty | Order size in base units (e.g., BTC) |
152 | CashOrderQty | Order size in quote units (e.g., USD) (Market order only) |
40 | OrdType | Must be 1 for Market, 2 for Limit, or 4 for Stop Limit |
99 | StopPx | Stop price for order |
59 | TimeInForce | Must be a valid TimeInForce value. See the table below (Limit order only) |
7928 | SelfTradePrevention | Optional, see the table below |
SelfTradePrevention Values
Value | Description |
---|---|
D | Decrement and cancel (the default) |
O | Cancel resting order |
N | Cancel incoming order |
B | Cancel both orders |
If an order is decremented due to self-trade prevention, an Execution Report is sent to the client with ExecType=D
indicating unsolicited OrderQty
reduction (i.e., partial cancel).
See the self-trade prevention documentation for more details about this field.
TimeInForce Values
Value | Description |
---|---|
1 | Good Till Cancel |
3 | Immediate or Cancel |
4 | Fill or Kill |
P | Post-Only |
The post-only flag (P
) indicates that the order should only make liquidity. If any part of the order results in taking liquidity, the order is rejected and no part of it executes. Open Post-Only orders are treated as Good Till Cancel.
See the time in force documentation for more details about these values.
Errors
If a trading error occurs (for example, the user has insufficient funds), an Execution Report with ExecType=8
is sent back, signifying that the order was rejected.
New Order Batch (U6)
Sent by the client to create multiple orders. Maximum of 10 orders per message. All orders must have the same Symbol. Each profile can place a maximum of 500 open orders on a product. Once reached, the profile cannot place any new orders until the total number of open orders is below 500. If the total number of open orders in the batch causes the profile to exceed the 500 maximum, the entire batch is rejected.
Tag | Name | Description |
---|---|---|
8014 | BatchID | UUID selected by client to identify this New Order Batch request |
73 | NoOrders | Number of orders in this message (number of repeating groups to follow). Must be less than or equal to 10. |
11 | ClOrdID | UUID selected by client for the order. Must be the first field in the repeating group. |
55 | Symbol | Required symbol to identify the new order (e.g., BTC-USD ) |
54 | Side | Must be 1 to buy or 2 to sell |
44 | Price | Limit price (e.g., in USD) |
38 | OrderQty | Order size in base units (e.g., BTC) |
40 | OrdType | Must be 2 for Limit |
59 | TimeInForce | Must be a valid TimeInForce value. See the table above |
7928 | SelfTradePrevention | Optional, see the table above |
Order Cancel Request (F)
Sent by the client to cancel an order.
Tag | Name | Description |
---|---|---|
11 | ClOrdID | UUID selected by client to identify this cancel request |
37 | OrderID | OrderID from the ExecutionReport with OrdStatus=New (39=0) |
41 | OrigClOrdID | ClOrdID from the New Order Single. When supplying this value, you do not need to supply an OrderID. |
55 | Symbol | Required symbol of the order to cancel (must match Symbol of the Order). |
58 | Text | Free format text string |
Order Status Request (H)
Sent by the client to obtain information about pending and done orders.
Tag | Name | Description |
---|---|---|
37 | OrderID | OrderID of order to be sent back. |
11 | ClOrdID | ClOrdID of order to be sent back. When supplying this value, you do not need to supply an OrderID. |
55 | Symbol | Required symbol to identify the order, e.g., BTC-USD |
Response
The response to an Order Status Request is an ExecutionReport with ExecType=I
. The ExecutionReport contains the ClOrdID
if the value is supplied. If the order cannot be found, the ExecutionReport has OrderID=0
.
Order Cancel Batch Request (U4)
Sent by the client to cancel multiple orders. Only 10 orders can be sent in a single message. All orders must have the same Symbol.
Tag | Name | Description |
---|---|---|
8014 | BatchID | UUID selected by client to identify this Order Batch Cancel Request |
73 | NoOrders | Number of orders in this message (number of repeating groups to follow). Must be less than or equal to 10. |
41 | OrigClOrdID | UUID selected by client for the order. Must be the first field in the repeating group. |
55 | Symbol | Required symbol of the order to cancel (must match Symbol of the Order) |
37 | OrderID | OrderID from the ExecutionReport with OrdStatus=New (39=0). If present, this field takes precedence over OrigClOrdID to identify the order (optional). |
11 | ClOrdID | UUID selected by client to identify this cancel request |
Response
When the message is invalid or an unexpected error occurs, an Order Cancel Batch Reject (U5) message is sent. When orders are cancelled, an Execution Report (8) is sent for each order canceled. When Order Cancel Batch Request (U4) is partially rejected (i.e., some orders are filled or already canceled), Order Cancel Reject (9) is sent for each rejected cancel.
Execution Report (8)
Sent by the server when an order is accepted, rejected, filled, or canceled. Also sent when the user sends an OrderStatusRequest
.
Tag | Name | Description |
---|---|---|
6 | AvgPx | Calculated average price of all fills on this order |
11 | ClOrdID | Only present on order acknowledgements, ExecType=New (150=0) |
14 | CumQty | Currently executed quantity for chain of orders |
37 | OrderID | OrderID from the ExecutionReport with ExecType=New (150=0) |
55 | Symbol | Symbol of the original order |
54 | Side | Must be 1 to buy or 2 to sell |
32 | LastShares | Amount filled (if ExecType=1). Also called LastQty as of FIX 4.3 |
44 | Price | Price of the fill if ExecType indicates a fill, otherwise the order price |
38 | OrderQty | OrderQty as accepted (may be less than requested upon self-trade prevention) |
151 | LeavesQty | Quantity open for further execution |
152 | CashOrderQty | Order size in quote units (e.g., USD) (Market order only) |
60 | TransactTime | Time the event occurred |
150 | ExecType | May be 1 (Partial fill) for fills, D for self-trade prevention, etc. |
39 | OrdStatus | Order status as of the current message |
103 | OrdRejReason | Insufficient funds=3 , Post-only=8 , Unknown error=0 |
136 | NoMiscFees | 1 (Order Status Request responses and fill reports) |
137 | MiscFeeAmt | Fee amount (absolute value for Order Status Request responses, percentage value for fill reports) |
138 | MiscFeeCurr | Fee currency |
139 | MiscFeeType | 4 (Exchange fees) (Order Status Request responses and fill reports) |
891 | MiscFeeBasis | 2 (Percentage fee basis) (fill report only) |
1003 | TradeID | Product unique trade id |
1057 | AggressorIndicator | Y for taker orders, N for maker orders |
58 | Text | Human-readable description of the reject or cancel (optional)
|
ExecType Values
ExecType | Description |
---|---|
0 | New Order |
1 | Partial Fill |
3 | Done |
4 | Canceled |
7 | Stopped |
8 | Rejected |
D | Restated (Order Changed due to STP) |
I | Order Status |
New Order Batch Reject (U7)
Sent by the server when a New Order Batch message is rejected.
Tag | Name | Description |
---|---|---|
8014 | BatchID | BatchID from the New Order Batch message |
58 | Text | Human-readable description of the error (optional) |
Order Cancel Reject (9)
Sent by the server when an Order Cancel Request cannot be satisfied, e.g., because the order is already canceled or completely filled.
Tag | Name | Description |
---|---|---|
11 | ClOrdID | As on the cancel request |
37 | OrderID | As on the cancel request |
41 | OrigClOrdID | As on the cancel request |
39 | OrdStatus | 4 if too late to cancel |
102 | CxlRejReason | 1 if the order is unknown |
434 | CxlRejResponseTo | 1 (Order Cancel Request) |
Order Cancel Batch Reject (U5)
Sent by the server when an Order Cancel Batch Request cannot be satisfied, e.g., because a Symbol was not present. This is not sent if no orders can be found.
Tag | Name | Description |
---|---|---|
11 | ClOrdID | As on the cancel request |
37 | OrderID | As on the cancel request |
Reject (3)
Sent by either side upon receipt of a message which cannot be processed, e.g., due to missing fields or an unsupported message type.
Tag | Name | Description |
---|---|---|
45 | RefSeqNum | MsgSeqNum of the rejected incoming message |
371 | RefTagID | Tag number of the field which caused the reject (optional) |
372 | RefMsgType | MsgType of the rejected incoming message |
58 | Text | Human-readable description of the error (optional) |
373 | SessionRejectReason | Code to identify reason for reject |
SessionRejectReason Values
The following values can be sent by the server.
Value | Description |
---|---|
1 | Required tag missing |
5 | Value is incorrect (out of range) for this tag |
6 | Incorrect data format for value |
11 | Invalid MsgType (35) |
Heartbeat (0)
Sent by both sides if no messages have been sent for (HeartBtInt x 0.75) seconds, as agreed upon during logon. May also be sent in response to a Test Request.
Tag | Name | Description |
---|---|---|
112 | TestReqID | Copied from the Test Request, if any |
Test Request (1)
May be sent at any time by either side.
Tag | Name | Description |
---|---|---|
112 | TestReqID | Free text |
Updated 20 days ago