roq-binance#
Links#
Purpose#
Maintain network connectivity with the Binance 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#
$ mamba install \
--channel https://roq-trading.com/conda/stable \
roq-binance
$ cp $CONDA_PREFIX/share/roq-binance/config.toml $CONFIG_FILE_PATH
# Then modify $CONFIG_FILE_PATH to match your specific configuration
$ roq-binance \
--name "binance" \
--config_file "$CONFIG_FILE_PATH" \
--client_listen_address "$UNIX_SOCKET_PATH" \
--service_listen_address "$TCP_LISTEN_PORT" \
--flagfile "$FLAG_FILE"
Config#
Flags#
$ roq-binance --help
|
Max depth. Unbounded is the default. |
|
URI |
|
Time to wait before retrying a rejected request. |
|
Terminate when getting a 403 response code. |
|
Depth limit. This choice has influence on request limits, please refer to exchange documentation. |
|
Time between listen key refresh. |
|
If the cancel request fails, the replacement will not be attempted |
|
Comma-separated list of network names. Optional. |
|
URI |
|
Max levels for snapshots. |
|
Conflated depth updates are published at a frequency of either 100ms or 1000ms. |
|
Report individual matches for trade summary? |
|
Subscription limit per web-socket connection |
|
Use the WebSocket API? |
|
URI |
|
Comma-separated list of network names. Optional. |
Environments#
# flagfile
--rest_uri=https://api.binance.com
--ws_uri=wss://stream.binance.com:9443/stream
--ws_api_uri=wss://ws-api.binance.com/ws-api/v3
# flagfile
--rest_uri=https://api.binance.us
--ws_uri=wss://stream.binance.us:9443/stream
Market Data#
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
GET /api/v3/exchangeInfo |
||
OrderEntry |
GET /api/v3/exchangeInfo |
||
OrderEntry |
GET /api/v3/depth |
See Flags |
|
Statistics#
Type |
Comments |
---|---|
|
(miniTicker) |
|
(miniTicker) |
|
(miniTicker) |
|
(miniTicker) |
Order Management#
Event |
Stream |
Messages |
Comments |
---|---|---|---|
DropCopy |
executionReport |
||
DropCopy |
executionReport |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
GET /api/v3/openOrders |
It is only possible to download open orders |
|
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
POST /api/v3/order |
||
Unavailable |
|||
OrderEntry |
DELETE /api/v3/order |
||
OrderEntry |
DELETE /api/v3/openOrders |
This request is per-symbol! Only executed for those symbols where the gateway has seen order actions or download. |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
OrderEntry |
/api/v3/order |
Order Types#
Type |
Comments |
---|---|
|
Mapped to |
|
Mapped to |
Time in Force#
Type |
Comments |
---|---|
|
Mapped to |
|
Mapped to |
|
Mapped to |
Position Effect#
Note
Not supported
Execution Instructions#
Type |
Comments |
---|---|
|
Maps |
Templates#
create_order
#
Field |
Values |
Comments |
---|---|---|
|
|
Exchange field is |
cancel_order
#
Field |
Values |
Comments |
---|---|---|
|
|
Exchange field is |
|
|
Exchange field is |
Account Management#
Event |
Stream |
Messages |
Comments |
---|---|---|---|
Unavailable |
|||
DropCopy |
outboundAccountInfo, outboundAccountPosition |
Event |
Stream |
Messages |
Comments |
---|---|---|---|
Unavailable |
|||
OrderEntry |
GET /api/v3/account |
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#
It is possible to see gateway warnings about dropped messages caused by order status reversal, e.g. seeing
WORKING
afterCOMPLETED
. This is partly due to REST vs WebSocket and partly due to exchange publishing bothNEW
andFILLED
order update messages for taker orders.The online documentation has a note about rejected messages never ping pushed into the user data stream. This effectively means that there’s the risk that you will have to wait for the gateway to detect timeout if the REST connection is disconnected right after an order request has been sent.
The exchange API supports a cancel-replace order request. This is supported by first placing a cancel order with
is_last=false
followed immediately by a create order withis_last=true
.Note
The two orders must share the same symbol.
Multiple order entry connections (REST or WS) may be supported by specifying a list of local network interfaces to bind to. The implementation will then round-robin requests between connections already in the ready-state.