roq-ftx#

Purpose#

  • Maintain network connectivity with the FTX 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

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

Conda#

$ conda install \
  --channel https://roq-trading.com/conda/stable \
  roq-ftx
$ cp $CONDA_PREFIX/share/roq-ftx/config.toml $CONFIG_FILE_PATH

# Then modify $CONFIG_FILE_PATH to match your specific configuration
$ roq-ftx \
      --name "ftx" \
      --config_file "$CONFIG_FILE_PATH" \
      --client_listen_address "$UNIX_SOCKET_PATH" \
      --metrics_listen_address "$TCP_LISTEN_PORT" \
      --flagfile "$FLAG_FILE"

Config#

Flags#

$ roq-ftx --help

--rest_download_freq

Download frequency for positions and funds, e.g. 30s

--rest_funding_rates_poll_freq

Download frequency for funding rates, e.g. 5s

--ws_order_book_checksum_every

Number of updates between validating order-book checksum (0 means never validate).

--cancel_on_disconnect

The Logon FIX message can be used to instruct the exchange to automatically cancel all orders if a disconnect has been detected.

--fix_oms_strict_validation

Can be used to enable more strict validation of order parameters, e.g. not allowing market orders if using FIX for order entry. Default is to send all order parameters to the exchange for validation. However, this could potentially have an adverse effect on the rate-limiter.

Environments#

# flagfile

--rest_uri=https://ftx.com
--ws_uri=wss://ftx.com/ws
--fix_uri=tcp+ssl://fix.ftx.com:4363

Market Data#

Event

Stream

Messages

Comments

roq::ReferenceData

MarketData

markets

roq::MarketStatus

MarketData

markets

roq::TopOfBook

MarketData

ticker

roq::MarketByPriceUpdate

MarketData

orderbook

roq::MarketByOrderUpdate

Unavailable

roq::TradeSummary

MarketData

trades

roq::StatisticsUpdate

MarketData, Scraper

markets, futures, future

Event

Stream

Messages

Comments

roq::ReferenceData

DropCopy

/api/markets, /api/futures

  • multiplier not available

  • special logic to derive quote and base currencies for futures

roq::MarketStatus

DropCopy

/api/markets, /api/futures

roq::TopOfBook

roq::MarketByPriceUpdate

roq::MarketByOrderUpdate

roq::TradeSummary

roq::StatisticsUpdate

DropCopy

/api/markets

Statistics#

Type

Comments

SETTLEMENT_PRICE

(future) mark

PRE_SETTLEMENT_PRICE

(future) marginPrice

UPPER_LIMIT_PRICE

(future) upperBound

LOWER_LIMIT_PRICE

(future) lowerBound

OPEN_INTEREST

(future) openInterest

INDEX_VALUE

(futures) index

Order Management#

Event

Stream

Messages

Comments

roq::OrderUpdate

OrderEntry

ExecutionReport (8)

roq::TradeUpdate

OrderEntry

ExecutionReport (8)

Event

Stream

Messages

Comments

roq::OrderUpdate

DropCopy

/api/orders, /api/orders/history

Not implemented

roq::TradeUpdate

DropCopy

/api/fills

Not implemented

Event

Stream

Messages

Comments

roq::CreateOrder

OrderEntry

NewOrderSingle (D)

roq::ModifyOrder

Unavailable

roq::CancelOrder

OrderEntry

OrderCancelRequest (F)

roq::CancelAllOrders

OrderEntry

OrderMassCancelRequest (q)

Event

Stream

Messages

Comments

roq::OrderAck

OrderEntry

ExecutionReport (8), OrderCancelReject (9), Reject (3)

Order Types#

Type

Comments

LIMIT

Mapped to '2' (FIX)

Time in Force#

Type

Comments

GTC

Mapped to '1' (FIX)

IOC

Mapped to '3' (FIX)

Position Effect#

Note

Not supported

Execution Instructions#

Type

Comments

PARTICIPATE_DO_NOT_INITIATE

Mapped to '6' (FIX)

DO_NOT_INCREASE

Mapped to 'E' (FIX)

Account Management#

Event

Stream

Messages

Comments

roq::PositionUpdate

roq::FundsUpdate

Event

Stream

Messages

Comments

roq::PositionUpdate

DropCopy

/api/account

roq::FundsUpdate

DropCopy

/api/wallet/balances

Streams#

Type

Comments

FIX

Primary purpose

  • support order management

Each connection

  • supports a single account

Type

Comments

REST

Primary purpose

  • live account updates, including orders and fills

Each connection

  • supports a single account

The master account is used to

  • discover the full list of symbols (by downloading exchange info)

  • request depth snapshots

Type

Comments

WebSocket

Primary purpose

  • live market data

  • reference data and markets (from the markets channel)

Each connection

  • supports a slice of the symbols

The first stream is used to

  • subscribe the markets channel

Constraints#

  • The gateway requires a master account definition to be functional. This is currently needed by the market data connection.

  • Rate-limit usage is not communicated by the exchange

  • Order book

    • Max depth is 100

  • Order download doesn’t reveal how many execution reports should arrive

    • The solution is to make the connection ready some time after the last downloaded execution report has been received

Comments#

  • Order book

    • Top-100 checksum is not being verified for latency reasons

    • Instructions to clear levels appear outside top 100

  • Order Management

    • TimeInForce is automatically converted to IOC if order size too small. (More details here.)

    • Have seen FIX execution reports with pending-cancel arrive after cancel. For this reason, all pending-cancel are dropped.

    • REST/WS is unreliable at this point. Ordering is a real issue. Also, the automatic conversion to IOC is causing issues because the WS orders channel reports the order to be closed oftentimes followed by a REST response with order details indicating the order is working (new).