Kraken Futures WebSocket API

The listed functions and data types allow to access to public and private (authenticated) websocket feeds.

FuturesWebSocketClient

KrakenEx.FuturesWebSocketModule.FuturesWebSocketClientType
FuturesWebSocketClient

Type that stores information about the client and can be used to establish public and private websocket connections for Kraken Futures trading.

Fields

  • key – Kraken Futures API key
  • secret – Kraken Futures Secret key
  • cancel_public_connection – can be set disable the active public websocket connection
  • cancel_private_connection – can be set to disable the active private websocket connection

The following will be managed by the connection:

  • new_challenge – newest signed message

  • last_challenge – last signed message

  • challenge_ready – is set if the challenge is signed

  • url – default websocket url for Kraken Futures

  • active_subscriptions – List of active subscribed feeds

  • pending_subscriptions – List of pending subscribtions

  • public_ws – Public connected websocket instance

  • private_ws – Private connected websocket instance

  • available_public_feeds – List of all public feeds

  • available_private_feeds – List of all private feeds

Exampless

  • FuturesWebSocketClient() – default, public client

  • FuturesWebSocketClient("the-api-key", "the-api-secret-key") – authenticated client for public and private requests

source

WebSocket utilities

KrakenEx.FuturesWebSocketModule.connectMethod
connect(
    client::FuturesWebSocketClient;
    callback::Core.Function,
    public::Bool=true,
    private::Bool=false
)

Can create up to two (one private and one public) websocket connections. The public and/or private websocket object will be stored within the FuturesWebSocketClient. Websocket feeds can be subscribed and unsubscribed after a successful connection. This function must be invoked using @async. Private websocket connections and privat feed subscriptions requre valid API keys on the passed FuturesWebSocketClient object.

Attributes

  • client::FuturesWebSocketClient – the FuturesWebSocketClient instance
  • callback::Core.Function – Callback function wich receives the websocket messages
  • public::Bool=true – switch to activate/deactivate the public websocket connection
  • private::Bool=false – switch to activate/deactivate the private websocket connection

Examples

julia> # ws_client = FuturesWebSocketClient() # unauthenticated
julia> ws_client = FuturesWebSocketClient("api-key", "secret-key") # authenticated
julia> on_message(msg::Union{Dict{String,Any},String}) = println(msg)
julia> con = @async connect(ws_client, callback=on_message)
julia> subscribe(client=ws_client, feed="ticker", products=["PI_XBTUSD", "PF_SOLUSD"]) # public feeds
julia> subscribe(client=ws_client, feed="open_orders") # private feed
julia> wait(conn)
source
KrakenEx.FuturesWebSocketModule.subscribeMethod
subscribe(; 
    client::FuturesWebSocketClient,
    feed::String,
    products::Union{Vector{String},Nothing}=nothing
)

Subscribe to a websocket feed.

Examples

julia> # ws_client = FuturesWebSocketClient() # unauthenticated
julia> ws_client = FuturesWebSocketClient("api-key", "secret-key") # authenticated
julia> on_message(msg::Union{Dict{String,Any},String}) = println(msg)
julia> con = @async connect(ws_client, callback=on_message)
julia> subscribe(client=ws_client, feed="ticker", products=["PI_XBTUSD", "PF_SOLUSD"]) # public feeds
julia> subscribe(client=ws_client, feed="open_orders") # private feed
julia> wait(conn)
source
KrakenEx.FuturesWebSocketModule.unsubscribeMethod
unsubscribe(;
    client::FuturesWebSocketClient,
    feed::String,
    products::Union{Vector{String},Nothing}=nothing
)

Unsubscribe from a subscribed feed.

Examples

julia> # ws_client = FuturesWebSocketClient() # unauthenticated
julia> ws_client = FuturesWebSocketClient("api-key", "secret-key") # authenticated
julia> on_message(msg::Union{Dict{String,Any},String}) = println(msg)
julia> con = @async connect(ws_client, callback=on_message)
julia> unsubscribe(client=ws_client, feed="ticker", products=["PI_XBTUSD", "PF_SOLUSD"]) # public feeds
julia> unsubscribe(client=ws_client, feed="open_orders") # private feed
julia> wait(conn)
source