roq-phemex

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

Supports

Products

Spot

Futures

Swap

Option

Orders & Quotes
Account

Funds

Position

Note

✅ = Available.

❎ = Not implemented.

❌ = Unavailable.

❶ The exchange protocol does not support streaming updates for reference data.

Using

$ roq-phemex [FLAGS]

Flags

$ roq-phemex --help
--exchange (phemex)

Exchange identifier

--rest_uri (https://testnet-api.phemex.com)

Exchange end-point

--rest_proxy

Proxy end-point

--rest_ping_freq (5s)

Ping frequency

--rest_ping_path (/public/time)

Ping path

--rest_request_timeout (30s)

Request timeout

--rest_download_orders_page_size (500)

Page size used when downloading orders

--rest_download_orders_begin (24h)

Download orders since (now - begin)

--rest_download_only_active_orders (false)

Download only active orders?

--rest_download_fills_page_size (500)

Page size used when downloading fills

--rest_download_fills_begin (24h)

Download fills since (now - begin)

--ws_uri (wss://testnet-api.phemex.com/ws)

Exchange end-point

--ws_ping_freq (15s)

Ping frequency

--ws_request_timeout (15s)

Request timeout

--ws_max_subscriptions_per_stream (20)

Maximum number of symbols per connection

--ws_mbp_depth (30)

Maximum depth to subscribe (0=full/100ms, 30/20ms)

--request_limit (20)

Request limit per interval

--request_limit_interval (1s)

Request limit monitor interval

--self_trade_prevention (CN)

Self-trade prevention: CN, CO, CB, DC

--encode_buffer_size (1048576)

Encode buffer size

--decode_buffer_size (10485760)

Decode buffer size

--mbp_allow_price_inversion (false)

Allow price inversion?

Environments

$ --flagfile $CONDA_PREFIX/share/roq-phemex/flags/prod/flags.cfg
# flagfile for the roq-phemex gateway

--rest_uri=https://api.phemex.com
--ws_uri=wss://ws.phemex.com
$ --flagfile $CONDA_PREFIX/share/roq-phemex/flags/test/flags.cfg
# flagfile for the roq-phemex gateway

--rest_uri=https://testnet-api.phemex.com
--ws_uri=wss://testnet-api.phemex.com/ws

Configuration

$ --config_file $CONDA_PREFIX/share/roq-phemex/config.toml

Important

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

# config template for the roq-phemex gateway

symbols = [
 "^BTCUSDT$",
 "^BTCPERP$",
]

[accounts]

  [accounts.A1]
  master = true
  login = "YOUR_PHEMEX_API_KEY_GOES_HERE"
  secret = "YOUR_PHEMEX_SECRET_GOES_HERE"
  symbols = [ ".*" ]

[users]

  [users.test]
  password = "1234"
  symbols = ".*"

  [users.trader]
  password = "secret"
  accounts = [ "A1" ]
  symbols = [ "BTCUSDT", "BTCPERP" ]

[rate_limits]

  [rate_limits.global]
    type = "ORDER_ACTION"
    aggregate = true
    request_limit = 100
    monitor_period = "10s"
    ban_period = "5m"

Market Data

Order Management

Comments

  • The authentication request is sometimes rejected due to “invalid token”. This seems intermittent and we have not yet found a good explanation for this. Upon seeing the error message, the gateway proceeds to disconnecting and trying again.

  • The REST connection only seems to report a “pending” order status. The final confirmation will arrive on the WS connection. Roq’s OMS should be able to filter between WS and REST based on proper sequencing.

  • ModifyOrder can not be supported. The exchange only support cancel-replace (not modify).

  • Positions are not reported as “lots”. There seems to be some base/quote conversion happening.

References

Common

Exchange