Skip to main content

FIX API

FIX (Financial Information eXchange) is a standard electronic messaging protocol for placing orders, receiving order updates, and cancelling orders. BTSE's FIX API is based on the FIX 4.2 specification.


Connection​

EnvironmentHostPort
Productiontcp+ssl://fix.btse.com9876
Testnettcp+ssl://fix.btse.io9876

Sessions for Spot and Futures are separated using SenderSubID:

SenderSubIDMarket
SPOTSpot trading
FUTURESFutures trading

Rate Limits​

GroupMessage TypesLimit
AuthLogon (A), Logout (5)2 per second
GeneralAll other messages30 per second

When a rate limit is exceeded, a Business Message Reject (j) is returned with BusinessRejectReason: 4 (application not available).


Common Request Attributes​

All client messages must include these fields:

TagNameDescription
8BeginStringMust be FIX.4.2
9BodyLengthBody length in bytes
34MsgSeqNumSequence number β€” starts at 1, increments per message. Duplicates/out-of-order are rejected. Reset on new connection.
35MsgTypeMessage type
49SenderCompIDClient API key
50SenderSubIDSPOT or FUTURES
52SendingTimeMessage send time (e.g. 20220916-07:29:07)
56TargetCompIDMust be <Brand />
10CheckSumMessage checksum

Messages​

Logon (A)​

Initiates a FIX session. Must be the first message sent. Only one session per connection.

TagNameValueDescription
35MsgTypeA
95RawDataLength96Length of RawData field
96RawData(hex)HMAC-SHA384 signature. Concatenate with FIX field separator (0x01): SendingTime + MsgType + MsgSeqNum + SenderCompID + TargetCompID, then HMAC-SHA384 with API secret
98EncryptMethod0Must be 0 (None)
108HeartBtInt30Heartbeat interval in seconds. Send heartbeats every Nβˆ’5 seconds
141ResetSeqNumFlagYMust be Y
5001ApplyNewSymbolNameYFutures only. Enables new symbol names (e.g. BTC-PERP). Without this field, only old names (e.g. BTCPFC) are accepted
example

Signature computation

// Concatenate fields with FIX separator (0x01):
// SendingTime + 0x01 + MsgType + 0x01 + MsgSeqNum
// + 0x01 + SenderCompID + 0x01 + TargetCompID
//
// Then: HMAC-SHA384(apiSecret, dataRaw)
// Hex-encode the result β†’ RawData (tag 96)

Heartbeat (0)​

Keeps the session alive. Send every Nβˆ’5 seconds where N is the heartbeat interval set in Logon.

TagNameValueDescription
35MsgType0
112TestReqID123If responding to a TestRequest, copy from the TestRequest

Test Request (1)​

Requests a heartbeat response.

TagNameValueDescription
35MsgType1
112TestReqID123Arbitrary string β€” echoed back in a Heartbeat

Logout (5)​

Terminates the session. The other side responds with another Logout message; connection closes afterwards.

TagNameValue
35MsgType5

New Order Single (D)​

Submits a new order. Supports Market and Limit orders.

TagNameValueDescription
35MsgTypeD
21HandlInst1Must be 1 (AutomatedExecutionNoIntervention)
11ClOrdIDorder123Unique client-selected order identifier
55SymbolBTC-USDSymbol name
40OrdType21: Market Β· 2: Limit
38OrderQty1.1Order size in base units (required for Limit and Market sell)
44Price18000Limit or Market buy price (required for Limit and Market buy)
54Side11: Buy Β· 2: Sell
59TimeInForce11: GTC Β· 3: IOC Β· 4: FOK Β· a: 30s Β· b: 5min Β· c: 1h Β· d: 12h Β· e: 1 week Β· f: 1 month
18ExecInst6Optional: E: reduce only Β· 6: post only
5002PositionIdBTC-PERP-USDTOptional. Position to reduce (Futures)
5003PositionModeONEWAYOptional. ONEWAY (default) Β· HEDGE Β· ISOLATED

On acceptance, an Execution Report (8) is returned.


Order Cancel Request (F)​

Requests cancellation of an open order. Provide only one of OrderID or OrigClOrdID.

TagNameValueDescription
35MsgTypeF
37OrderIDorder123System-assigned order ID
41OrigClOrdIDorder123Client-assigned order ID
55SymbolBTC-USDSymbol name

Returns an Execution Report (8) on success, or Order Cancel Reject (9) on failure.


Order Cancel Reject (9)​

Sent by the server when an Order Cancel Request fails.

TagNameValueDescription
35MsgType9
37OrderIDorder123Copied from cancel request (if provided)
41OrigClOrdIDorder123Copied from cancel request (if provided)
39OrdStatus44: Already cancelled Β· 8: Rejection
102CxlRejReason11: Unknown order Β· 99: Other
434CxlRejResponseTo1Always 1

Order Status Request (H)​

Queries order status. Provide only one of OrderID or OrigClOrdID. Use OrderID = * to request all pending orders.

TagNameValueDescription
35MsgTypeH
37OrderIDorder123Order to query, or * for all open orders
41OrigClOrdIDorder123Client order ID
54Side11: Buy Β· 2: Sell
55SymbolBTC-USDSymbol name

Returns an Execution Report (8) with ExecType=I. When no open orders exist, Text (58) returns "No open orders".


Execution Report (8)​

Sent by the server when: an order is filled, the order status changes, or in response to New Order Single, Order Cancel Request, or Order Status Request.

TagNameValueDescription
11ClOrdIDorder123Client order ID
12Commission0.002Trade fee (fill only)
13CommType3Always 3
14CumQty0.4Cumulative filled quantity
17ExecIDd840c8…Execution ID
31LastPx7999.25Fill price (fill only)
32LastShares0.4Fill quantity (fill only)
35MsgType8
37OrderIDd840c8…System order ID
38OrderQty1.2Original order quantity
39OrdStatus0Current order status (see table below)
44Price8000Original order price
54Side11: Buy Β· 2: Sell
55SymbolBTC-USDSymbol name
58TexttextRejection reason description
59TimeInForce61: GTC Β· 3: IOC Β· 4: FOK Β· 6: GTD Β· a–f: custom durations
60TransactTime20190525-08:26:38.989Order update timestamp
103OrdRejReason1111: UNSUPPORTED_ORDER_CHARACTERISTIC β€” see Text(58) for details
126ExpireTime20190525-08:26:38.989Required when TimeInForce=GTD and ExpireDate not set
150ExecType1Reason for this message (see table below)
151LeavesQty0.8Remaining open quantity
1057AggressorIndicatorYY: taker Β· N: maker (fill only)
5000LiquidationYY: on-market liquidation order

ExecType values:

ExecTypeDescription
0New order
1Partially filled
3Fully filled
4Order cancelled
5Order amended
7Order refund (self-trade)
8Rejected (response to New Order Single)
IOrder status (response to Order Status Request)

OrdStatus values:

OrdStatusDescription
0New order
1Partially filled
3Fully filled
4Cancelled
5Amended
7Refunded
8Rejected

Reject (3)​

Sent by the server in response to an invalid message.

TagNameValueDescription
35MsgType3
45RefSeqNum2Sequence number of rejected message
371RefTagID38Tag number of the rejected field
372RefMsgTypeDMessage type of the rejected message
58TextMissing quantityHuman-readable rejection reason
373SessionRejectReason1Code identifying rejection reason

Business Message Reject (j)​

Sent when a rate limit is exceeded.

TagNameExampleDescription
35MsgTypej
45RefSeqNum11Sequence number of rejected message
49SenderCompIDBTSEAlways <Brand />
56TargetCompIDc123...05aClient API key
57TargetSubIDSPOTSPOT or FUTURES
58Textexceeding rate limitDetails
372RefMsgTypeFMessage type of rejected message
380BusinessRejectReason4Always 4: application not available