roq-binance-futures

Important

This gateway is currently “work in progress” and at the earliest expected for release 0.8.x

Purpose

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

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 Japan (to be confirmed)

  • No test environment

Conda

1
2
3
conda install \
  --channel https://roq-trading.com/conda/stable \
  roq-binance-futures
1
2
3
cp $CONDA_PREFIX/share/roq-binance-futures/config.toml $CONFIG_FILE_PATH

# Then modify $CONFIG_FILE_PATH to match your specific configuration
1
2
3
4
5
6
roq-binance-futures \
      --name "binance-futures" \
      --config_file "$CONFIG_FILE_PATH" \
      --client_listen_address "$UNIX_SOCKET_PATH" \
      --metrics_listen_address "$TCP_LISTEN_PORT" \
      --flagfile "$FLAG_FILE"

Flags

1
roq-binance-futures --help

--rest_depth_limit

Depth limit. This choice has influence on request limits, please refer to exchange documentation.

--rest_listen_key_refresh_secs

Time between listen key refresh.

--ws_depth_levels

Max levels for snapshots.

--ws_depth_freq_msecs

Conflated depth updates are published at a frequency of either 100ms or 1000ms.

--ws_trade_details

Report individual matches for trade summary?

--ws_max_subscriptions

Subscription limit per web-socket connection

Environments

1
2
3
4
# flagfile

--rest_uri=https://fapi.binance.com
--ws_uri=wss://fstream.binance.com/ws
1
2
3
4
# flagfile

--rest_uri=https://testnet.binancefuture.com
--ws_uri=wss://stream.binancefuture.com/ws

Market Data

Event

Stream

Messages

Comments

roq::ReferenceData

Unavailable

roq::MarketStatus

Unavailable

roq::TopOfBook

MarketData

<symbol>@bookTicker

roq::MarketByPriceUpdate

MarketData

<symbol>@depth@<freq>

roq::MarketByOrderUpdate

Unavailable

roq::TradeSummary

MarketData

<symbol>@aggTrade

roq::StatisticsUpdate

MarketData

<symbol>@miniTicker, <symbol>@markPrice

Event

Stream

Messages

Comments

roq::ReferenceData

OrderEntry

GET /fapi/v1/exchangeInfo

There is no live feed

roq::MarketStatus

OrderEntry

GET /fapi/v1/exchangeInfo

There is no live feed

roq::TopOfBook

roq::MarketByPriceUpdate

OrderEntry

GET /fapi/v1/depth

See Flags

roq::MarketByOrderUpdate

roq::TradeSummary

roq::StatisticsUpdate

Statistics

Type

Comments

UPPER_LIMIT_PRICE

(miniTicker) highPrice

LOWER_LIMIT_PRICE

(miniTicker) lowPrice

OPEN_PRICE

(miniTicker) openPrice

CLOSE_PRICE

(miniTicker) closePrice

SETTLEMENT_PRICE

(markPrice) markPrice

PRE_SETTLEMENT_PRICE

(markPrice) estSettlePrice

INDEX_VALUE

(markPrice) indexPrice

FUNDING_RATE

(markPrice) fundingRate

Order Management

Event

Stream

Messages

Comments

roq::OrderUpdate

DropCopy

ORDER_TRADE_UPDATE

roq::TradeUpdate

DropCopy

ORDER_TRADE_UPDATE

Event

Stream

Messages

Comments

roq::OrderUpdate

OrderEntry

GET /fapi/v1/openOrders

It is only possible to download open orders

roq::TradeUpdate

OrderEntry

GET /fapi/v1/userTrades

There is a limit of 1000 trades

Event

Stream

Messages

Comments

roq::CreateOrder

OrderEntry

POST /fapi/v1/order

roq::ModifyOrder

Unavailable

roq::CancelOrder

OrderEntry

DELETE /fapi/v1/order

roq::CancelAllOrders

OrderEntry

DELETE /fapi/v1/allOpenOrders, DELETE /fapi/v1/batchOrders

Event

Stream

Messages

Comments

roq::OrderAck

OrderEntry

/fapi/v1/order

Order Types

TBD

Time in Force

TBD

Position Effect

TBD

Execution Instructions

TBD

Account Management

Event

Stream

Messages

Comments

roq::PositionUpdate

DropCopy

ACCOUNT_UPDATE

roq::FundsUpdate

DropCopy

ACCOUNT_UPDATE

Event

Stream

Messages

Comments

roq::PositionUpdate

OrderEntry

GET /fapi/v2/account, GET /fapi/v2/positionRisk

roq::FundsUpdate

OrderEntry

GET /fapi/v2/balance

Streams

Type

Comments

REST

Primary purpose

  • support order management

Each connection

  • supports a single account

  • maintains a listen key (used by the DropCopy stream)

The master account is used to

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

  • request depth snapshots

Rate-limit avoidance is implemented by

  • not using HTTP pipelining

  • monitoring the following HTTP headers

  • X-MBX-USED-WEIGHT-1M

  • blocking new requests for --rest_rate_limit_interval_secs seconds after receiving HTTP status 429 (too many requests)

Type

Comments

WebSocket

Primary purpose

  • live account updates, including orders and fills

Each connection

  • supports a single account

Type

Comments

WebSocket

Primary purpose

  • live market data

Each connection

  • supports a slice of the symbols

Constraints

  • It is only possible to download current order status for open orders. The implication is that backup procedures must be implemented to reoncile positions in the scenario where orders are completely filled during a disconnect

  • The newClientOrderId field (used by CreateOrder) must conform to the ^[\.A-Z\:/a-z0-9_-]{1,36}$ regular expression (ECMAScript). This restricts length and character used when supplying the routing_id field

  • The exchange will monitor rate-limit usage per IP address