BitMEX¶
roq-bitmex
Environments¶
Production¶
Option |
Value |
Type |
Comment(s) |
---|---|---|---|
|
|
WebSocket |
|
|
|
REST |
Installation¶
Conda¶
Install
conda install -y roq-bitmex
Configuration
cp $CONDA_PREFIX/share/roq-bitmex/config.toml $CONFIG_FILE_PATH
# then modify $CONFIG_FILE_PATH to match your specific configuration
Using
roq-bitmex \
--name "bitmex" \
--config-file "$CONFIG_FILE_PATH" \
--client-listen-address "$UNIX_SOCKET_PATH" \
--metrics-listen-address "$TCP_LISTEN_PORT" \
--ws uri "$WS_URI" \
--rest-uri "$REST_URI"
Flags¶
Only notable flags are mentioned here.
Please refer to roq-bitmex --help
for all flags.
- --cancel-on-disconnect
The
cancelAllAfter
WebSocket message can be used to instruct the exchange to automatically cancel all orders if exchange detects a disconnect.Warning
Do not rely on this feature: we have not been able to verify it works correctly!
- --cancel-all-after-secs
Only used when
--cancel-on-disconnect
is true.- --rest-allow-order-updates
Support fastest possible order updates by including any order response received on the REST connection.
Warning
You may see inconsistent order updates. This is especially true for partial fills and order modifications/cancelations.
Ansible¶
Edit your inventory file and add your server to the
roq_bitmex
group
[roq_bitmex]
MY_SERVER
Docker¶
docker pull roqtrading/roq-bitmex
Note
Please contact us, if you want to use the Docker image.
Implementation¶
Restrictions¶
It is very hard to guarantee proper sequential processing if we were to allow order acks/updates from Rest response as well as either of the two WebSocket channels
execution
andorder
. The choice is to prefer theexecution
channel for normal updates and error response (and timeout) for Rest requests. Unfortunately, consistency appears to come at the cost of added latency.Better latency can be enabled by allowing processing of Rest response and the
order
channel. See Flags.
- TradeUpdate, PositionUpdate
Work in progress.
Incoming Events¶
Event |
Connection |
Message(s) |
Comment(s) |
---|---|---|---|
ReferenceData |
WS |
Instrument |
|
MarketStatus |
WS |
Instrument |
|
TopOfBook |
WS |
Quote |
|
MarketByPrice |
WS |
OrderBookL2 |
|
MarketByOrder |
Not available |
||
TradeSummary |
WS |
Trade |
|
SessionStatistics |
Not available |
||
DailyStatistics |
Not available |
||
OrderAck |
REST |
Order |
Errors, only |
WS |
Execution |
||
OrderUpdate |
WS |
Execution |
|
TradeUpdate |
WS |
Execution |
|
PositionUpdate |
WS |
Position |
|
FundsUpdate |
Not available |
Outgoing Events¶
Event |
Connection |
Message(s) |
Comment(s) |
---|---|---|---|
CreateOrder |
REST |
order (POST) |
|
ModifyOrder |
REST |
order (PUT) |
|
CancelOrder |
REST |
order (DELETE) |
Comments¶
The exchange API’s do not appear particularly suitable for low latency trading:
Order action requests must be signed (which is expensive) and then sent over Rest
Rest response (order ack) could be lost possibly leaving the client in a situation where it must trigger timeout logic and/or issue operational alerts
Several WebSocket channels are used communicate order state possibly allowing for inconsistent order management by client