roq-kraken#

Important

This gateway needs sponsorship to complete certain features.

Purpose#

  • Maintain network connectivity with the Kraken 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 Costa Rica (to be confirmed, best source here)

Conda#

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

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

Config#

Flags#

$ roq-kraken --help
--exchange (kraken)

exchange identifier (string)

--encode_buffer_size (1048576)

encode buffer size

--decode_buffer_size (10485760)

decode buffer size

--mbp_allow_price_inversion (false)

allow price inversion?

--rest_uri (https://api.kraken.com)

REST end-point (URI)

--rest_proxy

proxy end-point (URI)

--rest_ping_freq (5s)

ping frequency

--rest_ping_path (/0/public/Time)

URI path used for REST connection keep-alive messages

--rest_request_timeout (30s)

request: timeout

--ws_public_uri (wss://beta-ws.kraken.com)

WebSocket end-point (URI)

--ws_public_ping_freq (5s)

ping frequency

--ws_public_request_timeout (15s)

request timeout

--ws_public_subscribe_book_depth (10)

book depth (size)

--ws_public_max_subscriptions_per_stream (128)

max subscriptions per connection (count)

--ws_private_uri (wss://beta-ws-auth.kraken.com)

WebSocket end-point (URI)

--ws_private_ping_freq (5s)

ping frequency

--ws_private_request_timeout (15s)

request timeout

Environments#

$ $CONDA_PREFIX/share/roq-kraken/flags
# flagfile for the roq-kraken gateway

--rest_uri=https://api.kraken.com
--ws_public_uri=wss://ws.kraken.com
--ws_private_uri=wss://ws-auth.kraken.com
# flagfile for the roq-kraken gateway

--rest_uri=https://beta-api.kraken.com
--ws_public_uri=wss://beta-ws.kraken.com
--ws_private_uri=wss://beta-ws-auth.kraken.com

Market Data#

Event

Stream

Messages

Comments

roq::ReferenceData

Unavailable

roq::MarketStatus

Unavailable

roq::TopOfBook

MarketData

spread

roq::MarketByPriceUpdate

MarketData

book

roq::MarketByOrderUpdate

Unavailable

roq::TradeSummary

MarketData

trade

roq::StatisticsUpdate

Not supported

Statistics#

Order Management#

Event

Stream

Messages

Comments

roq::OrderUpdate

DropCopy

openOrders

Not implemented

roq::TradeUpdate

DropCopy

ownTrades

Not implemented

Event

Stream

Messages

Comments

roq::OrderUpdate

roq::TradeUpdate

Event

Stream

Messages

Comments

roq::CreateOrder

DropCopy

addOrder

Not implemented

roq::ModifyOrder

Unavailable

roq::CancelOrder

DropCopy

cancelOrder

Not implemented

roq::CancelAllOrders

DropCopy

cancelAll

Not implemented

Event

Stream

Messages

Comments

roq::OrderAck

DropCopy

addOrder, cancelOrder

Not implemented

Order Types#

TBD

Time in Force#

TBD

Position Effect#

TBD

Execution Instructions#

TBD

Account Management#

Event

Stream

Messages

Comments

roq::PositionUpdate

roq::FundsUpdate

Event

Stream

Messages

Comments

roq::PositionUpdate

OrderEntry

/0/private/OpenPositions

Not implemented

roq::FundsUpdate

OrderEntry

/0/private/Balance, /0/private/TradeBalance

Not implemented

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 asset pairs)

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#

  • Rate-limit usage is not communicated by the exchange

Order book ends up in bad state

Downtime (scheduled or not) appears to not shutdown existing connections nor are established subscriptions unsubscribed. Worse, during downtime, what appears to be uninitialized order book data can be disseminated. (This was confirmed with Kraken support early May 2020).

Warning

We currently have no means to detect bad order book updates. At best, a parse exception will terminate your gateway with an unhandled excpetion.