roq-bybit#

Purpose#

  • Maintain network connectivity with the Bybit 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

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#

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

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

Config#

Flags#

$ roq-bybit --help

--api

  • spot

  • linear

  • inverse

  • option

--ws_mbp_depth

The required Market by Price depth. Please consult the Bybit documentation for specifics. The lowest latency feed is chose if this flag is undefined.

--download_trades_lookback

Download trades using this lookback period. Optional.

--download_trades_lookback_on_restart

Download trades using this lookback period at gateway restart. Optional.

--download_trades_limit

Exchange limit (100).

Environments#

# flagfile

--rest_uri=https://api.bybit.com
--ws_public_uri=wss://stream.bybit.com/v5/public
--ws_private_uri=wss://stream.bybit.com/v5/private
# flagfile

--rest_uri=https://api-testnet.bybit.com
--ws_public_uri=wss://stream-testnet.bybit.com/v5/public
--ws_private_uri=wss://stream-testnet.bybit.com/v5/private

Market Data#

Event

Stream

Messages

Comments

roq::ReferenceData

roq::MarketStatus

roq::TopOfBook

MarketData

  • orderbook.1.<symbol> (spot)

  • tickers.<symbols> (other)

roq::MarketByPriceUpdate

MarketData

orderbook.<ws_mbp_depth>.<symbol>

roq::MarketByOrderUpdate

roq::TradeSummary

MarketData

publicTrade.<symbol>

roq::StatisticsUpdate

MarketData

tickers.<symbol>

Event

Stream

Messages

Comments

roq::ReferenceData

Rest

/v5/market/instruments-info

roq::MarketStatus

Rest

/v5/market/instruments-info

roq::TopOfBook

roq::MarketByPriceUpdate

roq::MarketByOrderUpdate

roq::TradeSummary

roq::StatisticsUpdate

Statistics#

Type

Comments

HIGHEST_TRADED_PRICE

(tickers) h

LOWEST_TRADED_PRICE

(tickers) l

CLOSE_PRICE

(tickers) c

TRADE_VOLUME

(tickers) v

Order Management#

Event

Stream

Messages

Comments

roq::OrderUpdate

DropCopy

order

roq::TradeUpdate

DropCopy

execution

Event

Stream

Messages

Comments

roq::OrderUpdate

OrderEntry

/v5/order/realtime

roq::TradeUpdate

OrderEntry

/v5/execution/list

Event

Stream

Messages

Comments

roq::CreateOrder

OrderEntry

/v5/order/create

roq::ModifyOrder

OrderEntry

/v5/order/amend

roq::CancelOrder

OrderEntry

/v5/order/cancel

roq::CancelAllOrders

OrderEntry

/v5/order/cancel-all

Event

Stream

Messages

Comments

roq::OrderAck

OrderEntry

Order Types#

Type

Comments

MARKET

Mapped to 'MARKET' (JSON)

LIMIT

Mapped to 'LIMIT' or 'LIMIT_MAKER' (JSON)

Time in Force#

Type

Comments

GTC

Mapped to 'GTC' (JSON)

FOK

Mapped to 'FOK' (JSON)

IOC

Mapped to 'IOC' (JSON)

Position Effect#

Note

Not supported

Execution Instructions#

Type

Comments

PARTICIPATE_DO_NOT_INITIATE

Mapped to 'LIMIT_MAKER' (JSON)

Account Management#

Event

Stream

Messages

Comments

roq::PositionUpdate

DropCopy

position

roq::FundsUpdate

DropCopy

wallet

Event

Stream

Messages

Comments

roq::PositionUpdate

OrderEntry

/v5/position/list”

roq::FundsUpdate

OrderEntry

/v5/account/wallet-balance

Streams#

Type

Comments

REST

Primary purpose

  • discover the full list of symbols

Type

Comments

WebSocket

Primary purpose

  • live market data

Each connection

  • supports a slice of the symbols

Type

Comments

REST

Primary purpose

  • Order actions

Type

Comments

WebSocket

Primary purpose

  • order updates

Constraints#

  • The gateway can not simultaneously support all product categories due to overlapping symbol names, e.g. BTCUSDT being both spot and linear. For this reason, the --api flag controls the product category and, if necessary, the --name or --exchange flags must be configured to appropriately differentitate the sources.

  • The order channel doesn’t give us any information about last traded, only the aggregate fields (traded / remaining / average price) are available. The last trade price/quantity fields are therefore estimated.

    Note

    The execution channel will independently report the fills.

Comments#

  • TopOfBook is based on orderbook.1 for spot and tickers for all other categories.