roq-bybit-futures#

Important

There are different network end-points required for linear and inverse perpetuals/futures. The API’s are different but sufficiently similar to allow this gateway to support both. The implication of this is that you will need more instances of this gateway if you need support for both product groups.

Purpose#

  • Maintain network connectivity with the Bybit Futures exchange

  • Route exchange updates to connected clients

  • Route client requests to the relevant exchange accounts

  • Stream all messages to an event-log

Overview#

Products

Spot

Futures

Options

Note

Crypto and USDT margined products are NOT supported by the same API.

Market Data

Reference Data

Market Status

Top of Book

Market by Price (L2)

Market by Order (L3)

Trade Summary

Statistics

Order Management

Create

Modify

Cancel

Cancel All

Auto Cancellation

Account Management

Positions

Funds

  • Data center located in: TBD

Conda#

$ conda install \
  --channel https://roq-trading.com/conda/stable \
  roq-bybit-futures
$ cp $CONDA_PREFIX/share/roq-bybit-futures/config.toml $CONFIG_FILE_PATH

# Then modify $CONFIG_FILE_PATH to match your specific configuration
$ roq-bybit-futures \
      --name "bybit-futures" \
      --config_file "$CONFIG_FILE_PATH" \
      --client_listen_address "$UNIX_SOCKET_PATH" \
      --metrics_listen_address "$TCP_LISTEN_PORT" \
      --flagfile "$FLAG_FILE"

Flags#

$ roq-bybit-futures --help

--ws_subscribe_depth_levels

Order book L2 levels. Can be 25 (20ms delayed) or 200 (100ms delayed). Please refer to Bybit’s online documentation.

Environments#

USDT Perpetual#

# flagfile

--rest_uri=https://api.bybit.com
--ws_public_uri=wss://stream.bybit.com/realtime_public
--ws_private_uri=wss://stream.bybit.com/realtime_private
# flagfile

--api=linear
--rest_uri=https://api-testnet.bybit.com
--ws_public_uri=wss://stream-testnet.bybit.com/realtime_public
--ws_private_uri=wss://stream-testnet.bybit.com/realtime_private

Note

You may also specify --api="" (the default).

Important

Downloading symbols doesn’t allow us to detect the contract type. You can work around this by having this in your config file:

[symbols]
include = [ ".*USDT.*" ]

Inverse Futures#

# flagfile

--api=inverse
--rest_uri=https://api.bybit.com
--ws_public_uri=wss://stream.bybit.com/realtime
--ws_private_uri=wss://stream.bybit.com/realtime
# flagfile

--api=inverse
--rest_uri=https://api-testnet.bybit.com
--ws_public_uri=wss://stream-testnet.bybit.com/realtime
--ws_private_uri=wss://stream-testnet.bybit.com/realtime

Important

Downloading symbols doesn’t allow us to detect the contract type. You can work around this by having this in your config file:

[symbols]
include = [ ".*BTC.*" ]
exclude = [ ".*USDT.*" ]  # linear products

Market Data#

Event

Stream

Messages

Comments

roq::ReferenceData

roq::MarketStatus

roq::TopOfBook

MarketData

instrument_info.100ms.<symbol>

No quantity from exchange

roq::MarketByPriceUpdate

MarketData

orderBookL2_25.<symbol> or orderBookL2_200.100ms.<symbol>

25 levels are published at 20ms frequency, 200 levels as 100ms

roq::MarketByOrderUpdate

roq::TradeSummary

MarketData

trade.<symbol>

roq::StatisticsUpdate

MarketData

instrument_info.100ms.<symbol>

Statistics#

Type

Comments

SETTLEMENT_PRICE

(instrument_info) mark_price

INDEX_VALUE

(instrument_info) index_price

Order Management#

Event

Stream

Messages

Comments

roq::OrderUpdate

DropCopy

order

roq::TradeUpdate

DropCopy

execution

Event

Stream

Messages

Comments

roq::OrderUpdate

OrderEntry

/v2/private/order

roq::TradeUpdate

Event

Stream

Messages

Comments

roq::CreateOrder

OrderEntry

/v2/private/order/create

roq::ModifyOrder

OrderEntry

/v2/private/order/replace

roq::CancelOrder

OrderEntry

/v2/private/order/cancel

roq::CancelAllOrders

OrderEntry

/v2/private/order/cancelAll

Event

Stream

Messages

Comments

roq::OrderAck

Mapping#

TimeInForce

ExecutionInstruction

time_in_force

reduce_only

PARTICIPATE_DO_NOT_INITIATE

POST_ONLY

DO_NOT_INCREASE

true

GTC

GOOD_TILL_CANCEL

IOC

IMMEDIATE_OR_CANCEL

FOK

FILL_OR_KILL

Order Types#

Time in Force#

Position Effect#

Note

Not supported

Execution Instructions#

Account Management#

Event

Stream

Messages

Comments

roq::PositionUpdate

DropCopy

position

roq::FundsUpdate

DropCopy

wallet

Warning! unable to map due to missing currency

Event

Stream

Messages

Comments

roq::PositionUpdate

OrderEntry

/v2/private/position/list

roq::FundsUpdate

OrderEntry

/v2/private/wallet/balance

Warning! not currently parsed

Streams#

Type

Comments

REST

Primary purpose

  • download reference data

Type

Comments

WebSocket

Primary purpose

  • live market data

  • reference data and markets (from the markets channel)

Each connection

  • supports a slice of the symbols

The first stream is used to

  • subscribe the markets channel

Type

Comments

REST

Primary purpose

  • support order management

Each connection

  • supports a single account

Type

Comments

REST

Primary purpose

  • live account updates, including orders and fills

Each connection

  • supports a single account

The master account is used to

  • discover the full list of symbols (by downloading exchange info)

  • request depth snapshots

Constraints#

  • Order book snapshot messages have different structure for inverse and USDT. This is a reason for requiring the --api flag.

Comments#

  • Order download currently can’t discover the symbols to download. You should use the --test_order_symbols flag and provide a comma-separated list of symbols.