roq-bybit

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

roq-bybit

Description

roq-bybit is a gateway

Supports

Products

Spot

Futures

Options

Combos

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-Cancel

Account Management

Positions

Funds

Flags

$ roq-bybit --help
--exchange (bybit)

Exchange identifier

--api (pot)

API (spot, linear, inverse or option)

--rest_uri (https://api-testnet.bybit.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 (/v5/market/time)

Ping path

--rest_request_timeout (30s)

Request timeout

--rest_recv_window (5s)

Receive window (please refer to exchange documentation)

--rest_terminate_on_403 (false)

(TEST) Trigger program termination after receiving a 403 response code?

--rest_back_off_delay (30s)

(TEST) Time to wait before retrying a rejected request

--ws_public_uri (wss://stream-testnet.bybit.com/v5/public)

Exchange end-point

--ws_public_host

Host (when URI is an IP address)

--ws_private_uri (wss://stream-testnet.bybit.com/v5/private)

Exchange end-point

--ws_private_host

Host (when URI is an IP address)

--ws_ping_freq (5s)

Ping frequency

--ws_request_timeout (15s)

Request timeout

--ws_max_subscriptions_per_stream (100)

Maximum number of symbols per connection

--ws_mbp_depth (0)

Maximum depth

--download_trades_lookback (300s)

Lookback period when downloading trades (following a disconnect)

--download_trades_lookback_on_restart

Lookback period when downloading trades (initial download)

--download_trades_limit (100)

Maximum number of trades per response (exchange limit)

--mbp_allow_price_inversion (false)

Allow price inversion?

--request_limit (10)

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

Environments

$ $CONDA_PREFIX/share/roq-bybit/flags/prod/flags.cfg
# flagfile for the roq-bybit gateway
# exchange servers are located in AWS, Singapore

--rest_uri=https://api.bybit.com
--ws_public_uri=wss://stream.bybit.com/v5/public
--ws_private_uri=wss://stream.bybit.com/v5/private
$ $CONDA_PREFIX/share/roq-bybit/flags/test/flags.cfg
# flagfile for the roq-bybit gateway
# exchange servers are located in AWS, Singapore

--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

Configuration

$ $CONDA_PREFIX/share/roq-bybit/config.toml

Important

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

symbols = [
  "^BTCUSD[A-Z]?$",
  "^ETHUSD[A-Z]?$"
]

[accounts]

  [accounts.A1]
  master = true
  login = "YOUR_BYBIT_API_KEY_GOES_HERE"
  secret = "YOUR_BYBIT_SECRET_GOES_HERE"
  symbols = [ ".*" ]

[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

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.

References

Common

Bybit