krakex v0.1.1 Krakex View Source
Kraken API Client.
The Kraken API is divided into several sections:
Public market data
server_time/1
- Get server time.assets/2
- Get asset info.asset_pairs/2
- Get tradable asset pairs.ticker/2
- Get ticker information.ohlc/3
- Get OHLC data.depth/3
- Get order book.trades/3
- Get recent trades.spread/3
- Get recent spread data.
Private user data
balance/1
- Get account balance.trade_balance/2
- Get trade balance.open_orders/2
- Get open orders.closed_orders/2
- Get closed orders.query_orders/3
- Query orders info.trades_history/2
- Get trades history.query_trades/2
- Query trades info.open_positions/2
- Get open positions.ledgers/2
- Get ledgers info.query_ledgers/2
- Query ledgers.trade_volume/2
- Get trade volume.
Private user trading
add_order/5
(not implemented) - Add standard order.cancel_order/2
(not implemented) - Cancel open order.
Private user funding
deposit_methods/3
(not implemented) - Get deposit methods.deposit_addresses/4
(not implemented) - Get deposit addresses.deposit_status/4
(not implemented) - Get status of recent deposits.withdraw_info/5
(not implemented) - Get withdrawal information.withdraw/5
(not implemented) - Withdraw funds.withdraw_status/3
(not implemented) - Get status of recent withdrawals.withdraw_cancel/4
(not implemented) - Request withdrawal cancelation.
Link to this section Summary
Functions
Get tradable asset pairs
Get asset info
Get account balance
Get server time
Get recent spread data
Get ticker information
Get trade balance
Get recent trades
Link to this section Functions
asset_pairs(Krakex.Client.t(), keyword()) :: Krakex.API.response()
Get tradable asset pairs.
Takes the following keyword options:
:info
- info to retrieve."info"
- all info (default)."leverage"
- leverage info."fees"
- fees schedule."margin"
- margin info.
:pair
- list of asset pairs to get info on. Returns all (default)
Returns a map of asset pairs and a map of their info with the fields:
"altname"
- alternate pair name."aclass_base"
- asset class of base component."base"
- asset id of base component."aclass_quote"
- asset class of quote component."quote"
- asset id of quote component."lot"
- volume lot size."pair_decimals"
- scaling decimal places for pair."lot_decimals"
- scaling decimal places for volume."lot_multiplier"
- amount to multiply lot volume by to get currency volume."leverage_buy"
- array of leverage amounts available when buying."leverage_sell"
- array of leverage amounts available when selling."fees"
- fee schedule array in [volume, percent fee] tuples."fees_maker"
- maker fee schedule array in [volume, percent fee] tuples (if on maker/taker)."fee_volume_currency"
- volume discount currency."margin_call"
- margin call level."margin_stop"
- stop-out/liquidation margin level.
Example response:
{:ok, %{"BCHEUR" => %{"aclass_base" => "currency", "aclass_quote" => "currency",
"altname" => "BCHEUR", "base" => "BCH", "fee_volume_currency" => "ZUSD",
"fees" => [[0, 0.26], [50000, 0.24], [100000, 0.22], [250000, 0.2],
[500000, 0.18], [1000000, 0.16], [2500000, 0.14], [5000000, 0.12],
[10000000, 0.1]],
"fees_maker" => [[0, 0.16], [50000, 0.14], [100000, 0.12], [250000, 0.1],
[500000, 0.08], [1000000, 0.06], [2500000, 0.04], [5000000, 0.02],
[10000000, 0]], "leverage_buy" => [], "leverage_sell" => [],
"lot" => "unit", "lot_decimals" => 8, "lot_multiplier" => 1,
"margin_call" => 80, "margin_stop" => 40, "pair_decimals" => 1,
"quote" => "ZEUR"}}
assets(Krakex.Client.t(), keyword()) :: Krakex.API.response()
Get asset info.
Takes the following keyword options:
:info
- info to retrieve."info"
(default):aclass
- asset class."currency"
(default):asset
- list of assets to get info on. Returns all (default)
Returns a map of asset names and a map of their info with the fields:
"altname"
- alternate name."aclass"
- asset class."decimals"
- scaling decimal places for record keeping."display_decimals"
- scaling decimal places for output display.
Example response:
{:ok, %{"BCH" => %{"aclass" => "currency", "altname" => "BCH",
"decimals" => 10, "display_decimals" => 5}}}
balance(Krakex.Client.t()) :: Krakex.API.response()
Get account balance.
Returns a map with the asset names and balance amount.
Example response:
{:ok, %{"XXBT" => "0.0400000000", "XXRP" => "160.00000000", "ZEUR" => "67.6613"}}
depth(Krakex.Client.t(), binary(), keyword()) :: Krakex.API.response()
Get order book.
Returns the market depth for an asset pair.
Takes an asset pair and the following keyword options:
:count
- maximum number of asks/bids.
Returns a map of the asset pair and a map of the info with the fields:
"asks"
- ask side array of array entries (price, volume, timestamp)."bids"
- bid side array of array entries (price, volume, timestamp).
Example response:
{:ok,
%{"BCHEUR" => %{"asks" => [["2033.900000", "4.937", 1515082275],
["2034.000000", "0.548", 1515081910],
["2034.500000", "0.005", 1515081281],
["2034.800000", "4.637", 1515082048]],
"bids" => [["2025.000000", "1.024", 1515081702],
["2022.200000", "0.140", 1515078885],
["2022.100000", "0.280", 1515078852],
["2021.400000", "0.248", 1515080222]]}}}
ohlc(Krakex.Client.t(), binary(), keyword()) :: Krakex.API.response()
Get OHLC data.
An open-high-low-close chart is a type of chart typically used to illustrate movements in the price of a financial instrument over time. Each vertical line on the chart shows the price range (the highest and lowest prices) over one unit of time, e.g., one day or one hour Takes list of asset pairs to get info on.
Takes an asset pair and the following keyword options:
:interval
- time frame interval in minutes. 1 (default), 5, 15, 30, 60, 240, 1440, 10080, 21600:since
- return committed OHLC data since given id (exclusive).
Returns a map with the asset pair and a list of lists with the entries (time, open, high, low, close, vwap, volume, count) and:
"last"
- id to be used as since when polling for new, committed OHLC data.
Note: the last entry in the OHLC array is for the current, not-yet-committed frame and will
always be present, regardless of the value of :since
.
Example response:
{:ok,
%{"BCHEUR" => [[1515037200, "2051.7", "2051.7", "2051.7", "2051.7", "0.0", "0.00000000", 0],
[1515037260, "2051.7", "2051.7", "2045.0", "2045.0", "2045.0", "0.01500000", 1],
[1515037320, "2045.0", "2050.8", "2045.0", "2050.8", "2050.7", "2.37135868", 2],
[1515037380, "2050.8", "2050.8", "2050.8", "2050.8", "0.0", "0.00000000", 0],
...],
"last" => 1515080280}}
server_time(Krakex.Client.t()) :: Krakex.API.response()
Get server time.
This is to aid in approximating the skew time between the server and client.
Returns a map with the fields:
"unixtime"
- as unix timestamp."rfc1123"
- as RFC 1123 time format.
Example response:
{:ok, %{"rfc1123" => "Thu, 4 Jan 18 14:57:58 +0000", "unixtime" => 1515077878}}
spread(Krakex.Client.t(), binary(), keyword()) :: Krakex.API.response()
Get recent spread data.
Returns the spread data for an asset pair.
Takes an asset pair and the following keyword options:
:since
- return spread data since given id (inclusive).
Returns a map with the asset pair and a list of lists with the entries (time, bid, ask) and:
"last"
- id to be used as since when polling for new trade data.
Example response:
{:ok,
%{"BCHEUR" => [[1515079584, "2025.000000", "2025.000000"],
[1515079584, "2025.000000", "2036.100000"],
[1515079594, "2025.000000", "2025.000000"],
[1515079596, "2025.000000", "2026.000000"],
[1515080461, "2025.500000", "2034.100000"],
[1515080462, "2025.000000", "2034.100000"]],
"last" => 1515083299}}
ticker(Krakex.Client.t(), [binary()]) :: Krakex.API.response()
Get ticker information.
Takes list of asset pairs to get info on.
Returns a map of asset pairs and a map of their ticker info with the fields:
"a"
- ask array(price, whole lot volume, lot volume)."b"
- bid array(price, whole lot volume, lot volume)."c"
- last trade closed array(price, lot volume)."v"
- volume array(today, last 24 hours)."p"
- volume weighted average price array(today, last 24 hours)."t"
- number of trades array(today, last 24 hours)."l"
- low array(today, last 24 hours)."h"
- high array(today, last 24 hours)."o"
- today’s opening price.
Example response:
{:ok,
%{"BCHEUR" => %{"a" => ["2034.800000", "1", "1.000"],
"b" => ["2025.000000", "8", "8.000"], "c" => ["2025.000000", "0.03660000"],
"h" => ["2140.000000", "2227.600000"],
"l" => ["1942.000000", "1942.000000"], "o" => "2134.000000",
"p" => ["2021.440397", "2051.549114"], "t" => [3824, 6704],
"v" => ["1956.76538027", "4086.36386115"]}}}
trade_balance(Krakex.Client.t(), keyword()) :: Krakex.API.response()
Get trade balance.
Takes the following keyword options:
:aclass
- asset class."currency"
(default):asset
- base asset used to determine balance."ZUSD"
(default)
Returns a map with the fields:
"eb"
- equivalent balance (combined balance of all currencies)."tb"
- trade balance (combined balance of all equity currencies)."m"
- margin amount of open positions."n"
- unrealized net profit/loss of open positions."c"
- cost basis of open positions."v"
- current floating valuation of open positions."e"
- equity = trade balance + unrealized net profit/loss."mf"
- free margin = equity - initial margin (maximum margin available to open new positions)."ml"
- margin level = (equity / initial margin) * 100.
Note: Rates used for the floating valuation is the midpoint of the best bid and ask prices.
Example response:
{:ok,
%{"c" => "0.0000", "e" => "725.4974", "eb" => "1177.9857", "m" => "0.0000",
"mf" => "725.4974", "n" => "0.0000", "tb" => "725.4974", "v" => "0.0000"}}
trades(Krakex.Client.t(), binary(), keyword()) :: Krakex.API.response()
Get recent trades.
Returns the trade data for an asset pair.
Takes an asset pair and the following keyword options:
:since
- return committed OHLC data since given id (exclusive).
Returns a map with the asset pair and a list of lists with the entries (price, volume, time, buy/sell, market/limit, miscellaneous) and:
"last"
- id to be used as since when polling for new trade data.
Example response:
{:ok,
%{"BCHEUR" => [["2008.100000", "0.09000000", 1515066097.1379, "b", "m", ""],
["2008.200000", "0.24850000", 1515066097.1663, "b", "m", ""],
["2008.300000", "4.36233575", 1515066097.1771, "b", "m", ""],
["2005.000000", "0.04107303", 1515066117.0598, "s", "l", ""],
["2008.000000", "0.07700000", 1515066117.389, "b", "l", ""],
"last" => "1515076587511702121"}}