roq-okx¶
Important
The account must be configured for the “net” position mode (futures and swaps).
$ conda install \
--channel https://roq-trading.com/conda/unstable \
roq-okx
$ conda install \
--channel https://roq-trading.com/conda/stable \
roq-okx
Supports¶
✅ |
||
✅ |
||
✅ |
||
✅ |
||
❌ |
||
✅ |
||
✅ |
||
✅ |
Note
✅ = Available.
❎ = Not implemented.
❌ = Unavailable.
Using¶
$ roq-okx [FLAGS]
Flags¶
$ roq-okx --help
--exchange(okx)Exchange identifier
--trade_mode(cross)Trade mode (
cross,isolatedorcash)--test_margin_currencyTEST Margin currency used when placing new orders
--rest_uri(https://www.okx.com)Exchange end-point
--rest_hostHost (when URI is an IP address)
--rest_proxyProxy end-point
--rest_ping_freq(10s)Ping frequency
--rest_ping_path(/api/v5/public/time)Ping path
--rest_request_timeout(30s)Request timeout
--ws_public_uri(wss://ws.okx.com:8443/ws/v5/public)Exchange end-point
--ws_public_hostHost (when URI is an IP address)
--ws_private_uri(wss://ws.okx.com:8443/ws/v5/private)Exchange end-point
--ws_private_hostHost (when URI is an IP address)
--ws_business_uri(wss://ws.okx.com:8443/ws/v5/market)Exchange end-point
--ws_business_hostHost (when URI is an IP address)
--ws_ping_freq(5s)Ping frequency
--ws_max_subscriptions_per_stream(32)Maximum number of symbols per connection
--ws_books_depth(400)Depth defines what ‘books’ channel to subscribe to (some require authentication)
--ws_books_use_public(false)Only use publicly available data sources (not requiring VIP membership)?
--ws_disconnect_timeout(10s)Disconnect if connection has been silent for this period
--mbp_allow_price_inversion(false)Allow price inversion?
--request_limit(80)Maximum number of requests per interval
--request_limit_interval(10s)Monitor interval
--encode_buffer_size(1048576)Encode buffer size
--decode_buffer_size(10485760)Decode buffer size
--include_bad_subscriptions(false)TEST
--test_local_interfaceLocal interface
Environments¶
$ --flagfile $CONDA_PREFIX/share/roq-okx/flags/prod/flags.cfg
# flagfile for the roq-okx gateway
# exchange servers are located in Alibaba, Hong Kong, China
--rest_uri=https://www.okx.com
--ws_public_uri=wss://ws.okx.com:8443/ws/v5/public
--ws_private_uri=wss://ws.okx.com:8443/ws/v5/private
--ws_business_uri=wss://ws.okx.com:8443/ws/v5/business
$ --flagfile $CONDA_PREFIX/share/roq-okx/flags/test/flags.cfg
# flagfile for the roq-okx gateway
# exchange servers are located in Alibaba, Hong Kong, China
--rest_uri=https://www.okx.com
--ws_public_uri=wss://wspap.okx.com:8443/ws/v5/public?brokerId=9999
--ws_private_uri=wss://wspap.okx.com:8443/ws/v5/private?brokerId=9999
--ws_public_uri=wss://wspap.okx.com:8443/ws/v5/business
Configuration¶
$ --config_file $CONDA_PREFIX/share/roq-okx/config.toml
Important
This template will be replaced when the software is upgraded. Make a copy and modify to your own needs.
# config template for the roq-okx gateway
symbols = [
"^BTC-USD[A-Z]$", # spot
"^BTC-USD[A-Z]-SWAP$" # swap
]
[accounts]
[accounts.A1]
master = true
login = "YOUR_OKX_API_KEY_GOES_HERE"
password = "YOUR_OKX_PASSPHRASE_GOES_HERE"
secret = "YOUR_OKX_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¶
Inbound¶
Event
Field
tickers
open24h⇒
tickers
high24h⇒
tickers
low24h⇒
tickers
vol24h⇒
index-tickers
idxPx⇒
funding-rate
fundingRate⇒
funding-rate
nextFundingRate⇒
LIMITGTC→
limitfalse
LIMITGTCDO_NOT_INCREASE→
limittrue
LIMITGTCPARTICIPATE_DO_NOT_INITIATE→
post_onlyfalse
LIMITFOK→
fokfalse
LIMITIOC→
iocfalse
Outbound¶
|
|
||||
|---|---|---|---|---|---|
⇒ |
|
|
|||
⇒ |
|
|
|||
⇒ |
|
|
|||
⇒ |
|
|
|||
⇒ |
|
|
|||
⇒ |
|
|
TBD
TBD
TBD
Comments¶
Only VIP members can access the L2 tick-by-tick market data feed.
TopOfBook is throttled at 100ms (by exchange)
The
index-tickersandfunding-ratechannels are subscribed for all swaps and futures. This may generate some false subscriptions caused by non-existing channels. Unfortunately, there doesn’t seem to be any way to detect if a symbol has these channels available. The error messages are therefore only logged as warnings.Using the “batch-” version of the order operations due to 5x higher rate limit allowance.
There is no exchange API to support CancelAllOrders. This is therefore implemented by sending batch cancel requests for all known non-finished orders.
There are a number of different “books” channels which can be used as source for MarketByPrice. Some of these require authentication and VIP membership. The gateway will by default choose the most detailed lowest latency feed. This is however not always correct. In particular, the gateway has no knowledge of the VIP membership status. These are the flags you can use to override default behaviour
--ws_books_depth5 will use the
books5throttled snapshot feed50 will use the
books50-l2-tbtrealtime incremental feed400 will use either the
books-l2-tbtrealtime incremental feed or thebooksthrottled incremental feed.--ws_books_use_publicis an opt-out flag because the gateway will by default use a realtime feed if an account has been configured.References¶