roq-binance-futures#
Important
There are different network end-points required for USD-M and COIN-M futures.
The API’s are different but sufficiently similar to allow this gateway to
support both. (The --api
flag controls which API will be used.)
The implication of this is that you will need more instances of this gateway
if you need support for both product groups.
Links#
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#
Spot |
|
Futures |
✓ |
Options |
Note
Crypto and USDT margined products are NOT supported by the same API.
Reference Data |
✓ |
Market Status |
✓ |
Top of Book |
✓ |
Market by Price (L2) |
✓ |
Market by Order (L3) |
|
Trade Summary |
✓ |
Statistics |
✓ |
Create |
✓ |
Modify |
|
Cancel |
✓ |
Cancel All |
✓ |
Auto Cancellation |
✓ |
Positions |
✓ |
Funds |
✓ |
Data center located in Japan (to be confirmed)
No test environment
Conda#
$ mamba install \
--channel https://roq-trading.com/conda/stable \
roq-binance-futures
$ cp $CONDA_PREFIX/share/roq-binance-futures/config.toml $CONFIG_FILE_PATH
# Then modify $CONFIG_FILE_PATH to match your specific configuration
$ roq-binance-futures \
--name "binance-futures" \
--config_file "$CONFIG_FILE_PATH" \
--client_listen_address "$UNIX_SOCKET_PATH" \
--service_listen_address "$TCP_LISTEN_PORT" \
--flagfile "$FLAG_FILE"
Config#
Flags#
$ roq-binance-futures --help
|
The API URI name ( |
|
Max depth. Unbounded is the default. |
|
Default is to fail when receiving unknown event-types. |
|
Time between listen key refresh. |
|
Max levels for snapshots. |
|
Select frequency of depth stream: 100ms, 250ms or 500ms |
|
Subscription limit per web-socket connection |
|
Comma-separated list of symbols to download, e.g. |
|
Downloading trades using lookback period. Optional. |
|
Exchange limit (1000). |
Environments#
USD-M Futures#
# flagfile
--api=fapi
--rest_uri=https://fapi.binance.com
--ws_uri=wss://fstream.binance.com/ws
# flagfile
--api=fapi
--rest_uri=https://testnet.binancefuture.com
--ws_uri=wss://stream.binancefuture.com/ws
COIN-M Futures#
# flagfile
--api=dapi
--rest_uri=https://dapi.binance.com
--ws_uri=wss://dstream.binance.com/ws
# flagfile
--api=dapi
--rest_uri=https://testnet.binancefuture.com
--ws_uri=wss://dstream.binancefuture.com/ws
Market Data#
Event |
Stream |
Messages |
Comments |
---|---|---|---|
Unavailable |
|||
Unavailable |
|||
MarketData |
<symbol>@bookTicker |
||
MarketData |
<symbol>@depth@<freq> |
||
Unavailable |
|||
MarketData |
<symbol>@aggTrade |
||
MarketData |
<symbol>@miniTicker, <symbol>@markPrice |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
GET /fapi/v1/exchangeInfo |
There is no live feed |
|
OrderEntry |
GET /fapi/v1/exchangeInfo |
There is no live feed |
|
OrderEntry |
GET /fapi/v1/depth |
See Flags |
|
Statistics#
Type |
Comments |
---|---|
|
(miniTicker) |
|
(miniTicker) |
|
(miniTicker) |
|
(miniTicker) |
|
(markPrice) |
|
(markPrice) |
|
(markPrice) |
|
(markPrice) |
Order Management#
Event |
Stream |
Messages |
Comments |
---|---|---|---|
DropCopy |
ORDER_TRADE_UPDATE |
||
DropCopy |
ORDER_TRADE_UPDATE |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
GET /fapi/v1/openOrders |
It is only possible to download open orders |
|
OrderEntry |
GET /fapi/v1/userTrades |
There is a limit of 1000 trades |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
POST /fapi/v1/order |
||
Unavailable |
|||
OrderEntry |
DELETE /fapi/v1/order |
||
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 |
---|---|---|---|
OrderEntry |
/fapi/v1/order |
Order Types#
Type |
Comments |
---|---|
|
Mapped to |
|
Mapped to |
Time in Force#
Type |
Comments |
---|---|
|
Mapped to |
|
Mapped to |
|
Mapped to |
|
Mapped to |
Position Effect#
Note
Not supported
Execution Instructions#
TBD
Account Management#
Event |
Stream |
Messages |
Comments |
---|---|---|---|
DropCopy |
ACCOUNT_UPDATE |
||
DropCopy |
ACCOUNT_UPDATE |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
GET /fapi/v2/account |
||
OrderEntry |
GET /fapi/v2/balance |
Streams#
Type |
Comments |
---|---|
REST |
Primary purpose
Each connection
|
Type |
Comments |
---|---|
WebSocket |
Primary purpose
Each connection
|
Type |
Comments |
---|---|
WebSocket |
Primary purpose
Each connection
|
Type |
Comments |
---|---|
REST |
Primary purpose
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 byCreateOrder
) must conform to the^[.A-Z:/a-z0-9_-]{1,36}$
regular expression (ECMAScript). This restricts length and character used when supplying therouting_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.
Comments#
External trades can optionally be captured into the event log.
Note
These messages will not be routed to any client.
Trades can optionally be downloaded. This is a very expensive operation and the list of symbols to download must therefore be explicitly controlled by the
--download_symbols
flag.