From sgcWebSockets 4.4.8 Kraken Futures API is supported
The following APIs are supported:
WebSockets Public API: connects to a public WebSocket server.
WebSockets Private API: connects to a private WebSocket server and requires an API Key and API Secret to Authenticate against server.
REST Public API: connects to a public REST server.
REST Private API: connects to a public REST server and requires an API Key and API Secret to Authenticate against server.
Some public channels are provided without authentication. Example: you can subscribe to Ticker channel and get market data update through websocket protocol.
12345678910111213141516171819202122232425// Subscribe to a ticker calling SubscribeTicker method:SubscribeTicker(['PI_XBTUSD']);// If subscription is successful, OnKrakenFuturesSubscribed event will be called:procedure OnKrakenFuturesSubscribed(Sender: TObject; Feed, ProductId: string);beginDoLog('#subscribed: ' + Feed + ' ' + ProductId);end;//UnSubscribe calling UnSubscribeTicker method:UnSubscribeTicker(['PI_XBTUSD']);//If unsubscription is successful, OnKrakenFuturesUnSubscribed event will be called:procedure OnKrakenFuturesUnSubscribed(Sender: TObject; Feed, ProductId: string);beginDoLog('#unsubscribed: ' + Feed + ' ' + ProductId);end;// If there is an error while trying to subscribe / unsubscribe, OnKrakenFuturesError event will be called.procedure OnKrakenFuturesError(Sender: TObject; Error: string);beginDoLog('#error: ' + Error);end;
The subscribe and unsubscribe requests to WebSocket private feeds require a signed challenge message with the user api_secret.
The challenge is obtained as is shown in Section WebSocket API Public (using the api_key).
Authenticated requests must include both the original challenge message (original_challenge) and the signed (signed_challenge) in JSON format.
In order to get a Websockets Challenge, an API Key and API Secret must be set in Kraken Options Component, the api key provided by Kraken in your account
Example: Subscribe to AccountLog private channel.
12345678910111213141516171819202122232425262728293031323334353637// This subscription feed publishes account information.SubscribeAccountLog();// Later, you can unsubscribe from AccountLog, calling UnSubscribeAccountLog methodUnSubscribeAccountLog();Response example from server{'feed':'account_log_snapshot','logs':[{'id':1690,'date':'2019-07-11T08:00:00.000Z','asset':'bch','info':'fundingrate change','booking_uid':'86fdc252-1b6e-40ec-ac1d-c7bd46ddeebf','margin_account':'f-bch:usd','old_balance':0.01215667051,'new_balance':0.01215736653,'old_average_entry_price':0.0,'new_average_entry_price':0.0,'trade_price':0.0,'mark_price':0.0,'realized_pnl':0.0,'fee':0.0,'execution':'','collateral':'bch','funding_rate':-8.7002552653e-08,'realized_funding':6.9602e-07}]}
Use HTTP Protocol to get access to Public REST methods. Example: call GetOrderBook to get an snapshot of the Order Book of a Symbol.
12KrakenFutures.REST_API.GetOrderBook('PI_XBTUSD');
Use the REST Private API to get access to your private account, send orders, cancel orders...
1234567891011oOrder := TsgcHTTPKrakenFuturesOrder.Create;TryoOrder.Side := kosfBuy;oOrder.Symbol := 'PI_XBTUSD';oOrder.OrderType := kotfMKT;oOrder.Size := 1;KrakenFutures.REST_API.SendOrder(oOrder);FinallyoOrder.Free;End;
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.