roq-binance-futures

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

1conda install \
2  --channel https://roq-trading.com/conda/stable \
3  roq-binance-futures
1cp $CONDA_PREFIX/share/roq-binance-futures/config.toml $CONFIG_FILE_PATH
2
3# Then modify $CONFIG_FILE_PATH to match your specific configuration
1roq-binance-futures \
2      --name "binance-futures" \
3      --config_file "$CONFIG_FILE_PATH" \
4      --client_listen_address "$UNIX_SOCKET_PATH" \
5      --metrics_listen_address "$TCP_LISTEN_PORT" \
6      --flagfile "$FLAG_FILE"

Config

Flags

1roq-binance-futures --help

--rest_listen_key_refresh

Time between listen key refresh.

--ws_depth_levels

Max levels for snapshots.

--ws_depth_freq

Select frequency of depth stream: 100ms, 250ms or 500ms

--ws_max_subscriptions

Subscription limit per web-socket connection

Environments

1# flagfile
2
3--rest_uri=https://fapi.binance.com
4--ws_uri=wss://fstream.binance.com/ws
1# flagfile
2
3--rest_uri=https://testnet.binancefuture.com
4--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

HIGHEST_TRADED_PRICE

(miniTicker) highPrice

LOWEST_TRADED_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

This request is per-symbol! Only executed for those symbols where the gateway has seen order actions or download.

Event

Stream

Messages

Comments

roq::OrderAck

OrderEntry

/fapi/v1/order

Order Types

Type

Comments

MARKET

Mapped to 'MARKET' (JSON)

LIMIT

Mapped to 'LIMIT' (JSON)

Time in Force

Type

Comments

GTC

Mapped to 'GTC' (JSON)

IOC

Mapped to 'IOC' (JSON)

FOK

Mapped to 'FOK' (JSON)

GTX

Mapped to 'GTX' (JSON)

Position Effect

Note

Not supported

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

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)

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

Type

Comments

REST

Primary purpose

  • download reference data

One connection

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.

  • Rate-limit usage is quite strict when downloading full order books. Due to this constraint, it may take a very long time to initialize all symbols. It is therefore STRONGLY recommended to reduce the configured number of symbols, e.g. symbols=".*BTC.*", or even more specific by using lists.