FIX API

Deribit FIX API is a subset of FIX version 4.4. Deribit uses the standard header and trailer structure for all messages. To enable the API, sign in and go to Account -> Security -> API Tab and use the checkbox. Write down your ’Access Key’ and ’Access Secret. ’Access Secret’ is the user’s secret key provided by Deribit. Important Note: Do not reveal to anybody your ’Access Secret’, it is important as your password.

FIX SERVER ADDRESS

Socket host = deribit.com, socket port = 9880
Socket host = test.deribit.com, socket port = 9881 

Message Header

Each request message includes
Tag Name Required Comments
49 SenderCompID Yes SenderCompID user defined client name
 56 TargetCompID Yes TargetCompID constant value: DERIBITSERVER

LOGON(A)

LOGON(A) is the first message sent by the client to initiate a session. If authentication succeeds, the exchange should echo the message back to the client. If authentication fails, the exchange should send a LOGOUT(5) message with an appropriate reason.

Request Parameters

Tag Name Required Comments
108 HeartBtInt Yes Used to declare the timeout interval in seconds for generating heartbeats(same value used by both sides).
96 RawData Yes A Nonce, which is base64 encoded data of 32 random bytes, example “3pM14pgJOYBATBDaCmE+0YvdPExppg5bJXAZtxakwDQ=”
553 Username Yes API authenticated ’Access Key’
554 Password Yes base64 encoded data of SHA256 hash of concatenation the Nonce and ’Access Secret’ string, SHA256(Nonce ++ AccessSecret)

LOGOUT(5)

LOGOUT(5) can be sent by either party in order to terminate a session. The sending party should always wait for the echo of the logout request before they close the socket. Closing connections in any other way is considered abnormal behavior.

Request Parameters

Tag Name Required Comments
58 text No Free format text string specifying the logout reason.

HEARTBEAT(0)

When either end of a FIX connection has not sent or received any data for [HeartBtInt] seconds (as specified in the Logon (A) message), it will transmit a Heartbeat (0) message. When either end of a FIX connection has not received any data for [HeartBtInt] seconds, it will transmit a Test Request Message (1). If there is still no response, the session should be considered lost and corrective action should be initiated.

Request Parameters

Tag Name Required Comments
112 TestReqId No Required when the heartbeat is the result of a TestRequest (1) message

TEST REQUEST(1)

The Test Request (1) message forces a heartbeat from the opposing application. The opposing application responds with a Heartbeat (0) containing the original TestReqID.

Request Parameters

Tag Name Required Comments
112 TestReqId Yes Mirrors the original request ID.

RESEND REQUEST(2)

The Resend Request(2) message is used by the server to initiate the retransmission of messages. This function is utilized if a sequence number gap is detected, if the receiving application lost a message, or as a function of the initialization process.

Request Parameters

Tag Name Required Comments
7 BeginSeqNo Yes
16 EndSeqNo Yes

REJECT(3)

The Reject (3) message should be issued when a message is received but cannot be properly processed due to a session-level or data structure rule violation. An example of when a reject may be appropriate would be the receipt of a message with invalid basic data (e.g. missing tags) which successfully passes decryption.

Request Parameters

Tag Name Required Comments
45 RefSeqNum Yes MsgSeqNum of the rejected message
372 RefMsgType No The MsgType<35> of the FIX message being referenced
373 SessionRejectReason No Code to identity reason for rejection.
58 Text No Text string explaining the reason for rejection

MARKET DATA REQUEST(V)

Market Data Request (V) is used by the trading platform to request market data in the snapshot or the incremental form. Deribit uses his message for order book requests and its change notification.

Request Parameters

Tag Name Required Comments
55 Symbol Yes Instrument symbol
262 MdReqId Yes Unique ID assigned to this request.
263 SubscriptionRequestType Yes 0 = Snapshot, 1 = Snapshot + Subscribe, 2 = Unsubscribe
264 MarketDepth No Default 20
100007 DeribitTradeAmount No Amount of trades returned in the snapshot response to request for snapshot of recent trades, default – 20, maximum – 100000
100008 DeribitSinceTimestamp No UTC Timestamp in milliseconds (integer number of milliseconds), if specified, the response returns the trades happened since that DeribitSinceTimestamp, applicable to the request for recent trades snapshot
Group MDEntryTypes
267 NoMdEntryTypes No Number of entry types in the request.
=>269 MDEntryType Yes 0 = Bid (Bid side of the order book), 1 = Offer (Ask side of the order book), 2 = Trade (Info about recent trades)

MARKET DATA REQUEST REJECT(Y)

If a Market Data Request (V) message is not accepted, the exchange responds with a Market Data Request Reject (Y) message

Request Parameters

Tag Name Required Comments
58 Text No Free format text string
262 MDReqID Yes ID of the original request
281 MDReqRejReason Yes

MARKET DATA SNAPSHOT/FULL REFRESH (W)

Market Data Snapshot/Full Refresh (W) is used as the response to a Market Data Request (V) message.

Request Parameters

Tag Name Required Comments
55 Symbol Yes Instrument symbol
262 MDReqID No ID of the original request, if it is applicable
268 < NoMDEntries > Yes Repeating group . Specifies the number of entries in the group.
=>270 MDEntryPx No Price of an entry
=>271 MDEntrySize No Size of an entry
=>269 MDEntryType No 0 = Bid (Bid side of the order book), 1 = Offer (Ask side of the order book), 2 = Trade (in case of request for info about recent trades)
=>272 MDEntryDate No UTCTimestamp string (up to ms), e.g., timestamp for trade
=>100009 DeribitTradeId No Id of the trade, in case of the request for trades
=>54 Side No Side of trade (1 = Buy, 2 = Sell)
=>37 OrderId No For trade – order id
=>198 SecondaryOrderId No For trade – matching order id
=>39 OrdStatus No For trade – order status (0 = New, 1 = Partially filled, 2 = Filled, 4 = Canceled)
=>100010 DeribitLabel No User defined 4-char label of the order, in case of the request for trades

MARKET DATA INCREMENTAL REFRESH (X)

Market Data – Incremental Refresh (X) message is used for incremental updates in case of Market Data Request (V) for Snapshot + Subscribe

Request Parameters

Tag Name Required Comments
55 Symbol Yes Instrument symbol
262 MDReqID No ID of the original “subscribe” request
268 NoMDEntries Yes Number of entries following
=>279 MDUpdateAction Yes 0 = New, 1 = Change, 2 = Delete
=>269 MDEntryType No 0 = Bid (Bid side of the order book), 1 = Offer (Ask side of the order book), 2 = Trade (in case of request for info about recent trades)
=>270 MDEntryPx No Price of an entry
=>271 MDEntrySize No Size of an entry
=>272 MDEntryDate No UTCTimestamp string (up to ms), e.g., timestamp for trade
=>100009 DeribitTradeId No Id of the trade, in case of the request for trades
=>54 Side No Side of trade (1 = Buy, 2 = Sell)
=>37 OrderId No For trade – order id
=>198 SecondaryOrderId No For trade – matching order id
=>39 OrdStatus No For trade – order status (0 = New, 1 = Partially filled, 2 = Filled, 4 = Canceled)
=>100010 DeribitLabel No User defined 4-char label of the order, in case of the request for trades

NEW ORDER SINGLE(D)

The NEW ORDER SINGLE (D) is used by the client to submit new orders to the exchange. Note Deribit doesn’t store client identifiers (for the sake of speed of execution), i.e., client software should manage matching client-server identifiers using

Request Parameters

Tag Name Required Comments
11 ClOrdID Yes Unique identifier for the order as assigned by the client
54 Side Yes 1 = Buy, 2 = Sell
38 OrderQty Yes Order quantity
44 Price Yes Price
55 Symbol Yes Instrument symbol, e.g., “BTC-1JAN16”

EXECUTION REPORT(8)

Upon receiving a new order, the exchange responds with the Execution Report (8) message communicating whether the order was accepted or rejected.

Request Parameters

Tag Name Required Comments
11 ClOrdID Yes Deribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41 OrigClOrdId Yes The original value assigned by the client in the New Order Single (D) message
39 OrdStatus Yes 0 = New, 8 = Rejected
54 Side Yes 1 = Buy, 2 = Sell
60 TransactTime Yes Time the transaction represented by this Execution Report occurred. Fix timestamp.
151 LeavesQty Yes Order quantity open for further execution (LeavesQty = OrderQty – CumQty )
14 CumQty Yes Total executed quantity or 0.0
38 OrderQty Yes Order quantity
40 OrdType Yes 2 = Limit, Limit orders only
44 Price Yes Price
103 OrdRejReason Yes
58 Text No Free format text string, usually exceptions
207 SecurityExchange No “Deribit”
55 Symbol Yes Instrument symbol
6 AvgPx No Average execution price or 0.0 if not executed yet or rejected

ORDER CANCEL REQUEST(F)

ORDER CANCEL REQUEST (F) message requests the cancellation of a particular order. If an order has been partially filled, only the remaining quantity can be cancelled. The request should be accepted only if an order can successfully be cancelled without executing further. The server generated identifiers should be used as OrigClOrdId-s, Deribit doesn’t store client identifiers.

Request Parameters

Tag Name Required Comments
11 ClOrdID Yes Order identifier
41 OrigClOrdId Yes Order identifier assigned by Deribit

ORDER CANCEL REJECT(9)

ORDER CANCEL REJECT (9) is issued by the exchange upon receipt of Order Cancel Request (F) message which cannot be executed.

Request Parameters

Tag Name Required Comments
52 SendingTime Yes
11 ClOrdID Yes Order identifier
41 OrigClOrdId Yes Order identifier assigned by Deribit
39 OrdStatus No If it is applicable
58 Text No Text string explaining the reason for rejection

EXECUTION REPORT(8)

The following Execution Report (8) is sent by the exchange upon successfully processing a cancel request.

Request Parameters

Tag Name Required Comments
52 SendingTime Yes
11 ClOrdID Yes Deribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41 OrigClOrdId Yes The original value assigned by the client in the New Order Single (D) message
39 OrdStatus Yes 0 = New, 1 = Partial, 4 = Canceled, 8 = Rejected
58 Text Yes Text string describing the result

ORDER MASS STATUS REQUEST(AF)

Order Mass Status Request (AF) message requests the status of currently open orders. The exchange should respond with a series of Execution Report (8) messages detailing orders.

Request Parameters

Tag Name Required Comments
584 MassStatusReqID Yes Client-assigned unique ID of this request or OrderId if MassStatusReqType = 1
585 MassStatusReqType Yes Specifies the scope of the mass status request. 1 = status of a specified order(Tag584 is OrderId), 7 = Status for all orders

EXECUTION REPORT(8)

When the client requests the status of current orders, the exchange should reply with a series of special Execution Reports (8), one for every active order.

Request Parameters

Tag Name Required Comments
11 ClOrdID Yes Deribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41 OrigClOrdId Yes For Order Mass Status Request(AF), OrigClOrdId is equal to the ClOrdID, i.e., order identifier assigned by Deribit
39 OrdStatus Yes 0 = New, 1 = Partial, 2 = Filled, 3 = Done, 4 = Canceled, 8 = Rejected
54 Side Yes 1 = Buy, 2 = Sell
60 TransactTime Yes Time the transaction represented by this Execution Report occurred. Fix timestamp.
38 OrderQty Yes Order quantity
40 OrdType Yes 2 = Limit, Limit orders only
44 Price Yes Price
103 OrdRejReason Yes
58 Text No Free format text string, usually exceptions
207 SecurityExchange No “Deribit”
55 Symbol Yes Instrument symbol
6 AvgPx No Average execution price, filled.

REQUEST FOR POSITIONS (AN)

Request For Positions (AN) is used by the owner of a position to request a Position Report.

Request Parameters

Tag Name Required Comments
710 PosReqID Yes Unique identifier for the Request for Positions (AN) as assigned by the submitter.
724 PosReqType Yes 0 = Positions (currently)

POSITION REPORT (AP)

The Position Report (AP) message is returned by the holder of a position in response to a Request for Position (AN) message.

Request Parameters

Tag Name Required Comments
721 PosMaintRptID Yes Unique identifier for this position report
710 PosReqID No Unique identifier for the Request for Positions associated with this report.
724 PosReqType No 0 = Positions (currently)
728 PosReqResult No 0 = success, 1 = unsupported request for positions
702 NoPositions No \strikeout off\uuline off\uwave offNumber of position entries following
=>704 LongQty No Qty for long position (0 for short position)
=>705 ShortQty No Qty for short position (0 for long position)
=>55 Symbol No Instrument symbol
=>883 UnderlyingEndPrice No Mark price (reference price)
=>54 Side No 1 = Buy, 2 = Sell
=>730 SettlPrice No Average price
=>96 RawData No Additional info, semi-colon separated: maintenance margin;initial margin;floating P/L

USER REQUEST (BE)

USER REQUEST used to request a report on a user’s status and user account info

Request Parameters

Tag Name Required Comments
923 UserRequestID Yes The request ID
924 UserRequestType Yes Shoulr be equal to 4 (Request individual user status), only UserRequestType=4 supported for now
553 Username Yes API authenticated ’Access Key’, user can request only own info, should be the same as for previous LOGON(A)

USER RESPONSE (BF)

USER RESPONSE(BF) is used to respond to a USER REQUEST (BE) message, it reports the status of the user and user’s account info

Response Parameters

Tag Name Required Comments
923 UserRequestID Yes The request ID
553 Username Yes User’s API ’Access Key’
926 UserStatus N 1 = logged in, current implementation accepts USER REQUEST-s only from logged in users
100001 DeribitUserEquity N Equity of the user
100002 DeribitUserBalance N Balance of the user
100003 DeribitUserInitialMargin N Initial margin of the user
100004 DeribitUserMaintenanceMargin N Maintenance margin of the user
100005 DeribitUnrealizedPl N Unrealized P/L of the user
100006 DeribitRealizedPl N Realized P/L of the user
Example (Options)
Websockets API