FIX API
FIX (Financial Information eXchange) is a standard protocol which can be used to enter orders, submit cancel requests, and receive fills. Users of the FIX API typically have existing software using FIX for order management. Users who are not familiar with FIX should first consider using the REST API.
Presently, every connection establishes a new session and a new set of session sequence numbers.FIX API Endpoint URL
tcp+ssl://fix.prime.coinbase.com:4198
Connectivity
Before logging onto a FIX session, clients must establish a secure connection to the FIX gateway (fix.prime.coinbase.com:4198
). If your FIX implementation does not support establishing a TCP SSL connection natively, you must setup a local proxy such as stunnel to establish a secure connection to the FIX gateway. See the SSL Tunnels section for more details and examples.
Sessions are forcibly logged out every day between 5pm ET and 5:05pm ET for a maintenance window. All users are required to restart their sessions during this time and reset sequence numbers to 0.
Rate Limiting
Requests are limited to 50 calls per second/FIX session. We allow up to 7 sessions/portfolio.
Messages
The baseline specification for this API is FIX 4.2. Below, we've noted the places in which the FIX API for Coinbase Prime extends (or clarifies) the FIX spec. For example, there are custom tags with a four-digit number range, as allowed by the standard, which are unique to Prime.
A standard header must be present at the start of every message in both directions. You should configure your sessions to use the service account ID associated with the API key as your SenderCompID
and the string "COIN"
as the TargetCompID
. This is typically accomplished via your FIX client's configuration file.
Tag | Name | Description |
---|---|---|
8 | BeginString | Must be FIX.4.2 |
49 | SenderCompID | Service Account ID (on messages from the client) |
56 | TargetCompID | Must be COIN (on messages from the client) |
Logon (A)
// create a new Logon message
var logon = new Msgs.Logon();
logon.SendingTime = new Date();
logon.passphrase = '...';
var presign = [
logon.SendingTime,
logon.MsgType,
session.outgoing_seq_num,
apiKey,
session.target_comp_id,
passphrase
].join('');
// 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');
}
Sent by the client to initiate a session, and by the server as an acknowledgement. Only one session may exist per API key; sending a Logon message within an established session, or while the first session is still running, results in an error.
Tag | Name | Description |
---|---|---|
1 | Account | Portfolio ID associated with this API key |
96 | RawData | Client message signature (see below) |
554 | Password | Client API passphrase |
9407 | Access Key | Client API key |
The Logon message sent by the client must be signed for security. The prehash string is the following fields joined by the empty string:
{timestamp}, "A", seqNum, apiKey, targetComp, passphrase
.
There is no trailing separator. The RawData field should be a base64
encoding of the HMAC signature.
A single API key must not be used in multiple connections at the same time. To establish multiple FIX connections, generate a new API key for each one. All messages must have a SendingTime
value within 5 seconds of server time in UTC or they are rejected.
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.
Note that not every tag is required for every order -- it depends on the target strategy used. See the table below for more information.
Tag | Name | Description | Notes |
---|---|---|---|
1 | Account | The portfolio ID | |
11 | ClOrdID | A string selected by client to identify the order | |
38 | OrderQty | Order size in base units (e.g., BTC). Either this or CashOrderQty must be supplied. | |
40 | OrderType | The order type; see the table below for a list. | |
44 | Px | Indicates the price of the order | Required for Limit, TWAP, and SOR orders |
54 | Side | Must be 1 to buy or 2 to sell | |
55 | Symbol | The product to be traded (e.g., BTC-USD ) | |
59 | TimeInForce | A valid TimeInForce value; see the table below for a list. | |
126 | ExpireTime | Indicates the time and date of order expiration | Required for TWAP orders and Limit GTD orders |
152 | CashOrderQty | Order size in quote units (e.g., USD) | Either this or OrderQty must be supplied. |
168 | EffectiveTime | Indicates the start time | Required for TWAP orders |
847 | TargetStrategy | The target strategy of the order to place; see the table below for a list. |
TargetStrategy Values
Value | Description | OrderType | TimeInForce |
---|---|---|---|
L | Limit order | Must be 2 (Limit) | Must be 1 (GTC) or 6 (GTD); 44 (price) must also be provided |
M | Market order | Must be 1 (Market) | Must be 3 (IOC) |
T | TWAP order | Must be 2 (Limit) | Must be 6 (GTD); 44 (price) must also be provided |
OrderType Values
Value | Description |
---|---|
1 | Market |
2 | Limit |
TimeInForce Values
Value | Description |
---|---|
1 | Good Till Cancel (GTC) |
3 | Immediate or Cancel (IOC) |
6 | Good Till Date (GTD) |
Order Cancel Request (F)
Sent by the client to cancel an order.
Tag | Name | Description | Notes |
---|---|---|---|
1 | Account | The portfolio ID | |
11 | ClOrdId | ClOrdId identifying this cancel request | |
37 | OrderID | OrderID assigned by Coinbase (available in any of the Execution Report messages) | |
38 | OrderQty | Accepted order quantity. | You must supply this tag or CashOrderQty (depending on whichever you originally submitted) |
41 | OrigClOrdID | ClOrdID from the New Order Single. | You must also supply an OrderID. |
54 | Side | Must be 1 to buy or 2 to sell (depending on whichever you originally submitted) | |
55 | Symbol | The product from the original order (e.g., BTC-USD ) | |
152 | CashOrderQty | Order size in quote units (e.g., USD). | You must supply this tag or OrderQty (depending on which you submitted) |
Order Status Request (H)
->
MsgType=H
OrderID=3f8b09f2-3b25-4bf3-90be-330f7d68aee3
<-
MsgType=8
ClOrdID=3dce15be-3ad8-4cc9-85b6-55ec34c49069
OrderID=3f8b09f2-3b25-4bf3-90be-330f7d68aee3
Symbol=GNT-USDC
CumQty=0.00000000
Side=1
Price=0.01000000
ExecID=ece88c19-4aaa-404f-a525-2977f26664e7
ExecTransType=3
OrderQty=1.00000000
OrdStatus=0
OrdType=2
SenderCompID=Coinbase
SendingTime=20200710-14:48:23.577
TargetCompID=1e709a798e12f5a1a92e88852087d2g6
TransactTime=20200710-14:47:11.379
Commission=12
ExecType=I
Note: the Tags in this example have been replaced with Name for readability
Sent by the client to obtain information about pending and completed orders.
Tag | Name | Description | Notes |
---|---|---|---|
11 | ClOrdID | ClOrdID of the order to be sent back | |
37 | OrderID | OrderID of the order to be sent back | Required |
54 | Side | Must be 1 to buy or 2 to sell | |
55 | Symbol | The product to be traded (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
.
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 | Notes |
---|---|---|---|
6 | AvgPx | The average price of the order | |
11 | ClOrdID | ClOrdID of order to be sent back | |
12 | Commission | The Commission incurred for this fill | |
14 | CumQty | Total amount filled on this order | |
17 | ExecID | Free format text string | |
31 | LastPx | Price of the fill if ExecType indicates a fill, otherwise the order price | |
32 | LastQty | Amount currently filled | |
37 | OrderID | OrderID from the ExecutionReport | |
38 | OrderQty | OrderQty as accepted. | You must supply this tag or CashOrderQty (depending on whichever you originally submitted) |
39 | OrdStatus | Order status as of the current message | |
54 | Side | Must be 1 to buy or 2 to sell | |
55 | Symbol | Symbol of the original order | |
103 | OrdRejReason | Insufficient funds=3 , Post-only=8 , Unknown error=0 | |
150 | ExecType | Must be 1 (Partial fill) for fills, 4 for cancelled, etc. | |
151 | LeavesQty | Amount of order to be filled | |
152 | CashOrderQty | Order size in quote units (e.g., USD). | You must supply this tag or OrderQty (depending on whichever you originally submitted). |
ExecType Values
ExecType | Description |
---|---|
0 | New Order |
1 | Partial Fill |
2 | Filled |
3 | Done |
4 | Canceled |
6 | Pending Cancel |
7 | Stopped |
8 | Rejected |
D | Restated |
A | Pending New |
I | Order Status |
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 | The same value provided by the original cancel request |
37 | OrderID | The same value provided by the original cancel request |
39 | OrdStatus | The order status; see the table below for a list. |
41 | OrigClOrdID | The same value provided by the original cancel request |
102 | CxlRejReason | The reason the order was rejected |
434 | CxlRejResponseTo | The rejection response; see the table below for a list. |
OrdStatus Values
MiscFeeType | Description |
---|---|
0 | New |
1 | Partially filled |
2 | Filled |
3 | Done for day |
4 | Canceled |
5 | Replaced |
6 | Pending Cancel (e.g., result of Order Cancel Request <F> ) |
7 | Stopped |
8 | Rejected |
9 | Suspended |
A | Pending New |
B | Calculated |
C | Expired |
D | Accepted for bidding |
E | Pending Replace (e.g., result of Order Cancel/Replace Request <G> ) |
CxlRejResponseTo Values
MiscFeeType | Description |
---|---|
1 | Order Cancel Request <F> |
2 | Order Cancel/Replace Request <G> |
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 |
58 | Text | Human-readable description of the error (optional) |
371 | RefTagID | Tag number of the field which caused the reject (optional) |
372 | RefMsgType | MsgType of the rejected incoming message |
373 | SessionRejectReason | Code to identify reason for the reject (for session-level rejections only) |
SSL Tunnels
fix.prime.coinbase.com:4198
only accepts TCP connections secured by SSL. If your FIX client library cannot establish an SSL connection natively, you must run a local proxy that establishes a secure connection and allow unencrypted local connections.
Updated about 6 hours ago