roq-deribit

$ conda install \
      --channel https://roq-trading.com/conda/unstable \
      roq-deribit
$ conda install \
      --channel https://roq-trading.com/conda/stable \
      roq-deribit

Supports

Products

Spot

Futures

Swap

Option

Orders & Quotes
Account

Funds

Position

Note

✅ = Available.

❎ = Not implemented.

❌ = Unavailable.

Using

$ roq-deribit [FLAGS]

Flags

$ roq-deribit --help
--exchange (deribit)

Exchange identifier

--fix_uri (tcp://fix-test.deribit.com:9881)

Exchange end-point

--fix_ping_freq (5s)

Ping frequency

--fix_request_timeout (15s)

Request timeout

--fix_cancel_on_disconnect (true)

Auto-cancel orders on disconnect?

--fix_market_data_max_subscriptions_per_stream (256)

Maximum number of symbols per connection

--fix_market_data_request_max_size (56)

Max batch size (it appears there is a limit)

--fix_market_data_market_depth (20)

Market depth (see deribit documentation)

--fix_debug (false)

(DEBUG) Log fix messages?

--fix_continue_from_parse_exception (false)

(TEST) Continue if message can’t be parsed?

--fix_terminate_on_market_data_request_reject (false)

(TEST) Terminate if market data request has been rejected?

--fix_test_order_disconnect

(TEST) Disconnect order stream if silent for this period

--fix_test_order_logon

(TEST) Logon order stream after this period

--fix_test_market_data_disconnect

(TEST) Disconnect market data stream after this period

--rest_uri (https://test.deribit.com)

Exchange end-point

--rest_host

Host (when URI is an IP address)

--rest_proxy

Proxy end-point

--rest_ping_freq (5s)

Ping frequency

--rest_ping_path (/api/v2/public/get_time)

Ping path

--rest_request_timeout (30s)

Request timeout

--ws_uri (wss://test.deribit.com/ws/api/v2)

Exchange end-point

--ws_host

Host (when URI is an IP address)

--ws_ping_freq (5s)

Ping frequency

--ws_request_timeout (15s)

Request timeout

--ws_market_data_max_subscriptions_per_stream (256)

Maximum number of symbols per connection

--ws_ticker_interval (100ms)

Ticker interval

--ws_allow_errors (false)

(TEST) Allow errors

--ws_disable_quote (false)

Disable quote subscription

--multicast_config_file

Config file (path)

--multicast_channel_ids

Comma-separated list of multicast channels, e.g. 1)

--multicast_local_interface

Multicast local interface

--multicast_disable_top_of_book (false)

Default is to consume TopOfBook from the multicast feed

--multicast_disable_trade_summary (false)

Default is to consume TradeSummary from the multicast feed

--multicast_disable_market_by_price (false)

Default is to consume MarketByPrice from the multicast feed

--multicast_timeout (90s)

Timeout when waiting for snapshot

--mbp_allow_price_inversion (true)

Allow price inversion?

--request_limit (20)

Maximum number of requests per interval

--request_limit_interval (1s)

Monitor interval

--encode_buffer_size (1048576)

Encode buffer size

--decode_buffer_size (10485760)

Decode buffer size

--disable_deribit_143 (false)

(TEST) Disable #143

--disable_master_account_check (false)

(TEST) Disable requirement for master account

--test_local_interface

Local interface

--use_fix_reference_data (false)

Revert to using FIX to get ReferenceData?

Environments

$ --flagfile $CONDA_PREFIX/share/roq-deribit/flags/prod/flags.cfg
# flagfile for the roq-deribit gateway
# exchange servers are located in LD4, Equinix, Slough, UK

--fix_uri=tcp://fix.deribit.com:9881
--ws_uri=wss://www.deribit.com/ws/api/v2
--rest_uri=https://www.deribit.com
$ --flagfile $CONDA_PREFIX/share/roq-deribit/flags/test/flags.cfg
# flagfile for the roq-deribit gateway
# exchange servers are located in LD4, Equinix, Slough, UK

--fix_uri=tcp://fix-test.deribit.com:9881
--ws_uri=wss://test.deribit.com/ws/api/v2
--rest_uri=https://test.deribit.com

Configuration

$ --config_file $CONDA_PREFIX/share/roq-deribit/config.toml

Important

The template will be replaced when the software is upgraded. Make a copy and modify to your needs.

# config template for the roq-deribit gateway

symbols = [
  "^BTC-[0-9]{1,2}[A-Z]{3}[0-9]{2}$",  # futures
  "^ETH-[0-9]{1,2}[A-Z]{3}[0-9]{2}$",  # futures
  "^BTC(_USD[A-Z]?)?-PERPETUAL$",      # swaps
  "^ETH(_USD[A-Z]?)?-PERPETUAL$",      # swaps
  "^BTC(-USD[A-Z]?)?-DERIBIT-INDEX$",  # index
  "^ETH(-USD[A-Z]?)?-DERIBIT-INDEX$"   # index
]

[accounts]

  [accounts.A1]
  master = true
  symbols = [ ".*" ]
  login = "YOUR_DERIBIT_LOGIN_GOES_HERE"
  secret = "YOUR_DERIBIT_SECRET_GOES_HERE"

[users]

  [users.test]
  password = "1234"
  symbols = ".*"

  [users.trader]
  password = "secret"
  accounts = [ "A1" ]
  symbols = [ ".*BTC.*", ".*ETH.*" ]

[rate_limits]

  [rate_limits.global]
    type = "ORDER_ACTION"
    aggregate = true
    request_limit = 100
    monitor_period = "10s"
    ban_period = "5m"

Market Data

Inbound

state

closed

CLOSE

open

OPEN

created

UNDEFINED

settled

UNDEFINED

terminated

UNDEFINED

inactive

UNDEFINED

deactivated

UNDEFINED

started

UNDEFINED

Tag

Field

Value

Comment

746

OpenInterest

PRE_OPEN_INTEREST

100090

MarkPrice

PRE_SETTLEMENT_PRICE

269

MDEntryType

3

Index value

INDEX_VALUE

269

MDEntryType

6

Settlement price

SETTLEMENT_PRICE

Order Management

Inbound

Enum

MARKET

MARKET

LIMIT

LIMIT

Enum

GTC

GTC

IOC

IOC

FOK

FOK

GTX

GTX

Enum

NEW

WORKING

PARTIALLY_FILLED

WORKING

FILLED

COMPLETED

CANCELED

CANCELED

EXPIRED

EXPIRED

NEW_INSURANCE

UNDEFINED

NEW_ADL

UNDEFINED

Order Types

Type

Comments

MARKET

Mapped to '1' (FIX)

LIMIT

Mapped to '2' (FIX)

Time in Force

Type

Comments

GTC

Mapped to '1' (FIX)

IOC

Mapped to '3' (FIX)

FOK

Mapped to '4' (FIX)

Outbound

order_type

execution_instructions

price

stop_price

type

price

stopPrice

reduceOnly

MARKET

NaN

NaN

MARKET

MARKET

NaN

MARKET

LIMIT

NaN

LIMIT

LIMIT

LIMIT

TBD

TBD

TBD

Execution Instructions

Type

Comments

PARTICIPATE_DO_NOT_INITIATE

Mapped to '6' (FIX)

DO_NOT_INCREASE

Mapped to 'E' (FIX)

Comments

  • The gateway requires a master account definition to be functional. This is needed by the FIX protocol, even for the market data connection.

  • The field DeribitLabel (FIX tag 100010) is limited to 64 characters

  • The multicast feed can only be used by a single effective user id. This is a Linux restriction.

  • The multicast protocol is flawed due to the snapshot channel containing no more than 10k levels (on either side) and the events channel including book updates for all levels.

    Note

    There are currently no work-arounds implemented to deal with this.

  • The gateway must be restarted at least daily if you use the multicast feed. The reason is the snapshot vs events inconsistency mentioned under the constraints. The book effectively becomes more and more wrong for big market moves.

  • The exchange doesn’t notify us with the confirmed bar for time-series data.

roq-deribit-filter

$ roq-deribit-filter [FLAGS]

Description

roq-deribit-filter is a tool to generate the PCAP filter required to capture specific channels.

Flags

$ roq-deribit-filter --help
--type

Type of output, e.g. tcpdump.

--multicast_config_file

Multicast channel config file.

--multicast_channel_ids

Comma-separated list of multicast channels to include.

Example

$ roq-deribit-filter \
    --type "tcpdump" \
    --multicast_channel_ids 1,2 \
    --multicast_config_file "--flagfile $CONDA_PREFIX/share/roq-deribit/prod/channels.json"

(port 6100 or port 6101) and (host 239.111.111.1 or host 239.111.111.2)

This will output a tcpdump filter for channel_ids.

References

Common

Exchange