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.
Links#
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"
Config#
Flags#
$ roq-bybit-futures --help
|
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 |
---|---|---|---|
MarketData |
instrument_info.100ms.<symbol> |
No quantity from exchange |
|
MarketData |
orderBookL2_25.<symbol> or orderBookL2_200.100ms.<symbol> |
25 levels are published at 20ms frequency, 200 levels as 100ms |
|
MarketData |
trade.<symbol> |
||
MarketData |
instrument_info.100ms.<symbol> |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
Rest |
/v2/public/symbols |
||
Rest |
/v2/public/symbols |
||
Statistics#
Type |
Comments |
---|---|
|
(instrument_info) |
|
(instrument_info) |
Order Management#
Event |
Stream |
Messages |
Comments |
---|---|---|---|
DropCopy |
order |
||
DropCopy |
execution |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
/v2/private/order |
||
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
/v2/private/order/create |
||
OrderEntry |
/v2/private/order/replace |
||
OrderEntry |
/v2/private/order/cancel |
||
OrderEntry |
/v2/private/order/cancelAll |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
Mapping#
TimeInForce |
ExecutionInstruction |
time_in_force |
reduce_only |
|
---|---|---|---|---|
|
→ |
|
||
|
→ |
|
||
|
→ |
|
||
|
→ |
|
||
|
→ |
|
Order Types#
Time in Force#
Position Effect#
Note
Not supported
Execution Instructions#
Account Management#
Event |
Stream |
Messages |
Comments |
---|---|---|---|
DropCopy |
position |
||
DropCopy |
wallet |
Warning! unable to map due to missing currency |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
/v2/private/position/list |
||
OrderEntry |
/v2/private/wallet/balance |
Warning! not currently parsed |
Streams#
Type |
Comments |
---|---|
REST |
Primary purpose
|
Type |
Comments |
---|---|
WebSocket |
Primary purpose
Each connection
The first stream is used to
|
Type |
Comments |
---|---|
REST |
Primary purpose
Each connection
|
Type |
Comments |
---|---|
REST |
Primary purpose
Each connection
The master account is used to
|
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.