roq-kucoin#

Purpose#

  • Maintain network connectivity with the KuCoin 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 … (to be confirmed)

  • No test environment

Conda#

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

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

Config#

Flags#

$ roq-kucoin --help

--rest_download_delay

Time between download requests. Default is 333ms due to an exchange constraint of 9 requests / 3 seconds.

--rest_download_orders_page_size

The exchange API for order download is paginated and this is the number of items per page. Download will be disabled when set to zero.

--rest_download_orders_begin

When to include orders from. Default is 24 hours prior to “now”.

--rest_download_inactive

Also include inactive orders? Default is to only include active orders.

--rest_download_fills_page_size

The exchange API for fills download is paginated and this is the number of items per page. Download will be disabled when set to zero.

--rest_download_fills_begin

When to include orders from. Default is 24 hours prior to “now”.

Environments#

# flagfile

--rest_uri=https://api.kucoin.com
# flagfile

--rest_uri=https://openapi-sandbox.kucoin.com

Note

The WebSocket URI will be discovered by querying the REST service. There are therefore no additional flags to specify network end-points.

Market Data#

Event

Stream

Messages

Comments

roq::ReferenceData

roq::MarketStatus

MarketData

/market/snapshot

roq::TopOfBook

MarketData

/market/ticker

roq::MarketByPriceUpdate

MarketData

/market/level2

roq::MarketByOrderUpdate

roq::TradeSummary

MarketData

/market/match

roq::StatisticsUpdate

MarketData

/market/snapshot

Event

Stream

Messages

Comments

roq::ReferenceData

Rest

/api/v1/symbols

roq::MarketStatus

Rest

/api/v1/symbols

roq::TopOfBook

roq::MarketByPriceUpdate

Rest

/api/v3/market/orderbook/level2

roq::MarketByOrderUpdate

roq::TradeSummary

roq::StatisticsUpdate

Statistics#

Type

Comments

OPEN_PRICE

(snapshot) open

HIGHEST_TRADED_PRICE

(instrument) high

LOWEST_TRADED_PRICE

(instrument) low

CLOSE_PRICE

(instrument) close

OPEN_PRICE

(instrument) open

Order Management#

Event

Stream

Messages

Comments

roq::OrderUpdate

DropCopy

/spotMarket/tradeOrders

roq::TradeUpdate

Event

Stream

Messages

Comments

roq::OrderUpdate

roq::TradeUpdate

Event

Stream

Messages

Comments

roq::CreateOrder

OrderEntry

POST /api/v1/orders

roq::ModifyOrder

roq::CancelOrder

OrderEntry

DELETE /api/v1/orders/{order-id}

roq::CancelAllOrders

OrderEntry

DELETE /api/v1/orders

Event

Stream

Messages

Comments

roq::OrderAck

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)

Position Effect#

Note

Not supported

Execution Instructions#

Type

Comments

PARTICIPATE_DO_NOT_INITIATE

Mapped to postOnly (JSON). Requires GTC

Account Management#

Event

Stream

Messages

Comments

roq::PositionUpdate

roq::FundsUpdate

DropCopy

/account/balance

Event

Stream

Messages

Comments

roq::PositionUpdate

roq::FundsUpdate

OrderEntry

GET /api/v1/accounts

Streams#

Type

Comments

REST

Primary purpose

  • download reference data and L2 snapshot

Type

Comments

WebSocket

Primary purpose

  • live market data

  • market status

Each connection

  • supports a slice of the symbols

Type

Comments

REST

Primary purpose

  • download account data

  • order requests

Type

Comments

WebSocket

Primary purpose

  • live account data

  • order updates

  • fills

Constraints#

  • The gateway requires a master account definition (API key) to be functional. The reason is that requesting L2 snapshots will require authentication.

  • The exchange API does not allow order cancelation prior to an ack or update being received by the client. (Other exchanges normally allow cancelation using a client order id.) An roq::OrderAck with roq::Error::UNKNOWN_EXTERNAL_ORDER_ID is the response if a roq::CancelOrder request is sent “too early”.

  • There are no options to instruct the exchange to auto-cancel orders on disconnect.

Comments#

  • There is currently no implementation to refresh the token for the private connection. A received token should be valid for 24 hours and dialy restarts should therefore be planned.

  • The KuCoin sandbox environment does not work with IP restriction. This was confirmed by KuCoin support.