FIX API
Deribit FIX API is a subset of FIX version 4.4, but also includes some tags from 5.0 version and several custom tags. 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. 'Access Secret' is the user's secret key provided by Deribit. Important Note: Do not reveal to anybody your 'Access Secret', as it can be used to gain full control over your account.
The FIX server can be reached at www.deribit.com:9880
. The FIX server for the test network can be reached at test.deribit.com:9881
.
Each request message can include:
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
8 | BeginString |
String | Yes | Identifies beginning of new message and protocol version. Must always be first in the message. |
9 | BodyLength |
Length | Yes | Message length in bytes, not including fields 8, 9 and 10. See refer to FIX specification on how to compute this field. Must always be the first field in the message. |
35 | MsgType |
String | Yes | The type of the message. See below for available types |
49 | SenderCompID |
String | Yes | A user defined client name |
56 | TargetCompID |
String | Yes | Constant value: DERIBITSERVER |
34 | MsgSeqNum |
SeqNum | Yes | A sequence number for the message, starts with 1, and must be incremented by 1 for every message. |
52 | SendingTime |
UTCTimestamp | No | The time the request is sent. This field is ignored by the server |
10 | CheckSum |
String | Yes | The checksum of all of all preceding messages. See refer to FIX specification on how to compute this field. Must always be the last field in the message. |
Responses sent by the server will at least include:
Tag | Name | Type | Comments |
---|---|---|---|
8 | BeginString |
String | Identifies beginning of new message and protocol version. Must always be first in the message. |
9 | BodyLength |
Length | Message length in bytes, not including fields 8, 9 and 10. See refer to FIX specification on how to verify this field. Must always be the first field in the message. |
35 | MsgType |
String | The type of the message. See below for available types |
49 | SenderCompID |
String | Constant value: DERIBITSERVER |
56 | TargetCompID |
String | A user defined client name |
34 | MsgSeqNum |
SeqNum | A server-chosen sequence number for the message. |
52 | SendingTime |
UTCTimestamp | The time the request is sent. This field is ignored by the server |
10 | CheckSum |
String | The checksum of all of all preceding messages. See refer to FIX specification on how to verify this field. Must always be the last field in the message. |
Logon
(A
)
Logon
(A
) must 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 will respond with a LogOut
(5
) message with an appropriate reason.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
108 | HeartBtInt |
int | Yes | Used to declare the timeout interval in seconds for generating heartbeats. |
96 | RawData |
Yes | data | Base64 encoded nonce (see below) |
553 | Username |
Yes | String | API Access Key. This can be obtained from the API tab on your account settings. |
554 | Password |
Yes | String | See below |
9001 | CancelOnDisconnect |
Boolean | No | Boolean, to enable or disable session-level cancel on disconnect. Default - false(N ). |
The RawData
(96
) tag should be a base64 encoded nonce. The nonce consists of randomly chosen bytes. If a nonce is re-used, the authentication will fail. For safety reasons, it is important that the nonce is sufficiently long. We recommend at least 32 bytes. The nonce can be up to 512 bytes.
The Password
(553
) tag should contain a base64 encoded SHA256 hash of the nonce and the access secret: base64(sha256(nonce ++ access_secret))
.
CancelOnDisconnect
(9901
) controls "Close on Disconnect". If this tag is not provided, the default setting from the account is used.
Response
When the login is successful, the server will echo back the request.
If the login was not successful, the server will respond with a Logout
(5
) message, and close the connection.
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 behaviour. Nonetheless, if CancelOnDisconnect
(9001
) was set at Logon, all orders will be cancelled at Logout.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
58 | text |
String | No | Free format text string specifying the logout reason. This is ignored by the server |
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
(1
) message. If there is still no response, the session should be considered lost and corrective action should be initiated.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
112 | TestReqId |
String | Varies | The identifier when responding to Test Request (1 ) message. When not responding to a Test Request (1 ) message, this tag can be left out |
Response
When the heartbeat has been received successfully, the server will echo back the request as confirmation.
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 TestReqID
(112
).
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
112 | TestReqId |
String | 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.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
7 | BeginSeqNo |
Yes | The first message to repeat | |
16 | EndSeqNo |
Yes | The last message to repeat |
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.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
45 | RefSeqNum |
SeqNum | Yes | MsgSeqNum (34 ) of the rejected message |
372 | RefMsgType |
String | No | The MsgType (35 ) of the FIX message being referenced |
373 | SessionRejectReason |
int | No | Code to identity reason for rejection. See FIX specification for possible values. |
58 | Text |
String | No | Text string explaining the reason for rejection. |
Security List Request
(x
)
The SecurityListRequest
(x
) message is used to return a list of securities (instruments) from the Deribit.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
320 | SecurityReqId |
String | Yes | A user-generated ID for this request. This can be used to match the request to the response. |
559 | SecurityListRequestType |
int | Yes | 0 or 4 – in any case list of instruments is returned |
Response
The server will respond with a Security List
(y
) message, where the SecurityReq
(320
) is equal to that of the request.
Security List
(y
)
The SecurityList
(y
) message is used to return a list of securities that matches the criteria specified in a Security List Request
(x
).
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
320 | SecurityReqId |
String | Yes | The SecurityReqId (320 ) of the request that this is a response for |
322 | SecurityResponseID |
string | Yes | Identifier for the Security List (x ) message |
560 | SecurityRequestResult |
int | Yes | 0 indicates a successful response. This is the only possible value in the Deribit FIX API |
146 | NoRelatedSym |
int | N | Specifies the number of repeating instruments specified |
=>55 | Symbol |
String | N | Common, "human understood" representation of the security, e.g., BTC-28JUL17 , see instrument naming convention |
=>107 | SecurityDesc |
String | N | Free form security description. At the time of writing, this is either 'future' or 'option' |
=>167 | SecurityType |
String | N | FUT or OPT |
=>201 | PutOrCall |
int | N | Used to express option right, 0 – call, 1 – put. |
=>202 | StrikePrice |
Price | N | Strike price |
=>947 | StrikeCurrency |
Currency | N | Strike Currency |
=>15 | Currency |
N | Currency | Currency of option |
=>2576 | InstrumentPricePrecision |
int | N | number of decimal places for instrument prices (usually 4 for options, 2 for futures) |
=>225 | IssueDate |
UTCTimestamp | N | Date instrument was issued. |
=>541 | MaturityDate |
UTCTimestamp | N | Expiration date, YYYYMMDD |
=>1079 | MaturityTime |
UTCTimestamp | N | Expiration time |
=>562 | MinTradeVol |
Qty | N | The minimum trading volume for a security |
=>63 | SettlType |
String | N | Indicates order settlement period. E.g., M1 – month, W1 – week, W2 – 2 weeks etc |
=>120 | SettlCurrency |
Currency | N | Currency code of settlement denomination. |
=>479 | CommCurrency |
Currency | N | Specifies currency to be use for Commission. |
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.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
55 | Symbol |
String | Yes | Instrument symbol |
262 | MdReqId |
String | Yes | Unique ID assigned to this request. |
263 | SubscriptionRequestType |
int | Yes | 0 = Snapshot, 1 = Snapshot + Subscribe, 2 = Unsubscribe |
264 | MarketDepth |
int | No | Default 20 |
100007 | DeribitTradeAmount |
int | No | Amount of trades returned in the snapshot response to request for snapshot of recent trades, default 20, maximum 100000 |
100008 | DeribitSinceTimestamp |
int | No | UTC Timestamp in milliseconds (integer number of milliseconds), if specified, the response returns the trades happened since that timestamp, applicable to the request for recent trades snapshot |
Group MDEntryTypes |
||||
267 | NoMdEntryTypes |
int | Yes | Number of entry types in the request. |
=>269 | MDEntryType |
int | Yes | 0 = Bid (Bid side of the order book), 1 = Offer (Ask side of the order book), 2 = Trade (Info about recent trades) |
Response
If the server is unable to supply the requested data, it will respond with a Market Data Request Reject
(Y
) message.
If the request called for a snapshot (i.e. SubscriptionRequestType
(263
)=0 or SubscriptionRequestType
(263
)=1), the server will respond with a Market Data - Snapshot/Full Refresh
(W
) message.
If the request called for a snapshot (i.e. SubscriptionRequestType
(263
)=0 or SubscriptionRequestType
(263
)=1), the server will start sending with a Market Data - Incremental Refresh
(X
) messages.
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
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
58 | Text |
String | No | Free format text string |
262 | MDReqID |
String | Yes | ID of the original request |
281 | MDReqRejReason |
char | 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.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
55 | Symbol |
String | Yes | Instrument symbol |
262 | MDReqID |
String | No | ID of the original request, if it is applicable |
100087 | TradeVolume24h |
Qty | No | Defines 24h trade volume for the Symbol in the corresponding contract units |
268 | NoMDEntries |
int | Yes | Repeating group . Specifies the number of entries in the group. |
=>269 | MDEntryType |
int | 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 |
Price | No | Price of an entry |
=>271 | MDEntrySize |
Qty | No | Size of an entry |
=>272 | MDEntryDate |
UTCTimestamp | No | Timestamp for trade |
=>100009 | DeribitTradeId |
int | No | Id of the trade, in case of the request for trades |
=>54 | Side |
int | No | Side of trade (1 = Buy, 2 = Sell) |
=>37 | OrderId |
String | No | For trade – order id |
=>198 | SecondaryOrderId |
String | No | For trade – matching order id |
=>39 | OrdStatus |
No | int | For trade – order status (0 = New, 1 = Partially filled, 2 = Filled, 4 = Cancelled) |
=>100010 | DeribitLabel |
No | String | User defined 32 character 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
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
55 | Symbol |
String | Yes | Instrument symbol |
262 | MDReqID |
String | No | ID of the original request, if it is applicable |
100087 | TradeVolume24h |
Qty | No | Defines 24h trade volume for the Symbol in the corresponding contract units |
268 | NoMDEntries |
int | Yes | Repeating group . Specifies the number of entries in the group. |
=>269 | MDEntryType |
int | 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 |
Price | No | Price of an entry |
=>271 | MDEntrySize |
Qty | No | Size of an entry |
=>272 | MDEntryDate |
String | UTCTimestamp | Timestamp for trade |
=>100009 | DeribitTradeId |
int | No | Id of the trade, in case of the request for trades |
=>54 | Side |
int | No | Side of trade (1 = Buy, 2 = Sell) |
=>37 | OrderId |
String | No | For trade – order id |
=>198 | SecondaryOrderId |
String | No | For trade – matching order id |
=>39 | OrdStatus |
No | int | For trade – order status (0 = New, 1 = Partially filled, 2 = Filled, 4 = Cancelled) |
=>100010 | DeribitLabel |
No | String | User defined 32 character label of the order, in case of the request for trades |
=>44 | IndexPrice |
Price | No | For trades, this is the index price at the trade moment (Deribit index). |
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.
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
11 | ClOrdID |
String | Yes | Unique identifier for the order as assigned by the client |
54 | Side |
int | Yes | 1 = Buy, 2 = Sell |
38 | OrderQty |
Qty | Yes | Order quantity |
44 | Price |
Price | Yes | Price |
55 | Symbol |
String | Yes | Instrument symbol, e.g., BTC-1JAN16 |
18 | ExecInst |
int | No | Currently is used to place POST ONLY orders: 6 = "Participate don't initiate" |
40 | OrdType |
char | No | Order type. Valid values: 1 = Market, 2 = Limit. (default Limit) |
59 | TimeInForce |
char | No | Specifies how long the order remains in effect. Absence of this field is interpreted as "Good Till Cancel". Valid values: 1 = Good Till Cancel (GTC ), 3 = Immediate or Cancel (IOC ), 4 = Fill or Kill (FOK ) |
Response
Upon receiving a new order, the exchange responds with the Execution Report
(8
) message communicating whether the order was accepted or rejected.
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 |
char | 0 = New, 8 = Rejected |
54 | Side |
char | 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 |
1362 | NoFills |
No | Number of immediate fill entries for the order |
=>1363 | FillExecID |
No | Unique identifier of execution, concatenated via '#' symbol and trade sequence number, e.g., BTC-28SEP18#38 . |
=>1364 | FillPx |
No | Price of this partial fill |
=>1365 | FillQty |
No | Quantity bought/sold on this partial fill |
Order Cancel Request
(F
)
This 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
, Deribit doesn't store client identifiers.
Arguments
Tag | Name | Required | Comments |
---|---|---|---|
11 | ClOrdID |
Yes | Order identifier |
41 | OrigClOrdId |
Yes | Order identifier assigned by Deribit |
Response on failure
Order Cancel Reject
(9
) is issued by the exchange upon receipt of Order Cancel Request
(F
) message which cannot be executed.
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 |
Response on success
The following Execution Report
(8
) is sent by the exchange upon successfully processing a cancel request.
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 = Cancelled, 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.
Arguments
Tag | Name | Required | Comments |
---|---|---|---|
584 | MassStatusReqID |
Yes | Client-assigned unique ID of this request |
585 | MassStatusReqType |
Yes | Specifies the scope of the mass status request. (see below) |
This message can be used in two ways: to request status of all your open orders, or to request the status of a single order (which needn't be open).
To request the status of all orders, choose a random MassStatusRequestId
, and set MassStatusReqType=7
. The server will respond with a series of Execution Reports
(8
) messages, where the first message contains MassStatusReqType=7
and TotNumReports
will be set to the number of reports to be expected as a follow-up.
Response
When the client requests the status of current orders, the exchange should reply with a series of special Execution Reports
(8
), one for every order requested.
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
11 | ClOrdID |
string | 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 |
string | Yes | For Order Mass Status Request (AF ), OrigClOrdId is equal to the ClOrdID , i.e., order identifier assigned by Deribit |
39 | OrdStatus |
char | Yes | 0 = New, 1 = Partial, 2 = Filled, 3 = Done, 4 = Cancelled, 8 = Rejected |
54 | Side |
char | Yes | 1 = Buy, 2 = Sell |
60 | TransactTime |
UTCTimestamp | Yes | Time the transaction represented by this Execution Report occurred. |
38 | OrderQty |
Qty | Yes | Order quantity |
40 | OrdType |
char | Yes | 2 = Limit, Limit orders only |
44 | Price |
Price | Yes | Price |
103 | OrdRejReason |
int | Yes | See fix specification for possible values |
58 | Text |
String | No | Free format text string, usually exceptions |
207 | SecurityExchange |
String | No | "Deribit" |
55 | Symbol |
String | Yes | Instrument symbol |
6 | AvgPx |
Price | No | Average execution price, filled. |
When responding to a MassStatusReqType=7
request, the server precedes the Execution Reports
(8
) messages with a special Execution Reports
(8
) message:
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
584 | MassStatusReqID |
String | Yes | The MassStatusReqID from the request. (Only for the first message response to a MassStatusReqType=7 request.) |
585 | MassStatusReqType |
int | Yes | The MassStatusReqType from the request. (Only for the first message response to a MassStatusReqType=7 request.) |
911 | TotNumReports |
int | Yes | The total number of reports following this initial report |
Request For Positions
(AN
)
Request For Positions
(AN
) is used by the owner of a position to request a Position Report.
Arguments
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) |
Response
The server will respond with a Position Report
(AP
) message.
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.
Arguments
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 | Number 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
)
This message is used to request a report on a user's status and user account info.
Arguments
Tag | Name | Required | Comments |
---|---|---|---|
923 | UserRequestID |
Yes | The request ID |
924 | UserRequestType |
Yes | Should 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 ) |
Response
The server will respond with a User Response
(BF
) message.
User Response
(BF
)
This message is used to respond to a USER REQUEST
(BE
) message, it reports the status of the user and user's account info.
Arguments
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 |
Order Cancel/Replace Request
(G
)
To change/edit the parameters of an existing order
Arguments
Tag | Name | Type | Required | Comments |
---|---|---|---|---|
41 | OrigClOrdID |
String | Yes | |
11 | ClOrdId |
String | Yes | |
60 | TransactTime |
UTCTimestamp | Yes | |
54 | Side |
char | Yes | original side, 1=buy, 2=sell |
38 | OrderQty |
Qty | order quantity | |
40 | OrdType |
char | Yes | currently 2 - 'limit' |
44 | Price |
Price | order price | |
55 | Symbol |
String | instrument name, while not required, the server will be able to respond faster if it is supplied. |