kraken_api v0.1.0 KrakenApi View Source
Documentation of all the API calls and the corresponding parameters.
Link to this section Summary
Functions
Add standard order
Cancel open order
Get account balance
Get asset info
Get closed orders
Get ledgers info
Get OHLC data
Get open orders
Get open positions
Get order book
Get recent spread data
Get recent trades
Get the server time
Get ticker information
Get tradable asset pairs
Get trade balance
Get trade volume
Get trades history
Query ledgers
Query orders info
Query trades info
Link to this section Functions
Add standard order
Params:
- pair = asset pair
- type = type of order (buy/sell)
ordertype = order type:
- market
- limit (price = limit price)
- stop-loss (price = stop loss price)
- take-profit (price = take profit price)
- stop-loss-profit (price = stop loss price, price2 = take profit price)
- stop-loss-profit-limit (price = stop loss price, price2 = take profit price)
- stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price)
- take-profit-limit (price = take profit trigger price, price2 = triggered limit price)
- trailing-stop (price = trailing stop offset)
- trailing-stop-limit (price = trailing stop offset, price2 = triggered limit offset)
- stop-loss-and-limit (price = stop loss price, price2 = limit price)
- settle-position
- price = price (optional. dependent upon ordertype)
- price2 = secondary price (optional. dependent upon ordertype)
- volume = order volume in lots
- leverage = amount of leverage desired (optional. default = none)
oflags = comma delimited list of order flags (optional):
- viqc = volume in quote currency (not available for leveraged orders)
- fcib = prefer fee in base currency
- fciq = prefer fee in quote currency
- nompp = no market price protection
- post = post only order (available when ordertype = limit)
starttm = scheduled start time (optional):
- 0 = now (default)
- +
= schedule start time seconds from now = unix timestamp of start time
expiretm = expiration time (optional):
- 0 = no expiration (default)
- +
= expire seconds from now = unix timestamp of expiration time
- userref = user reference id. 32-bit signed number. (optional)
- validate = validate inputs only. do not submit order (optional)
optional closing order to add to system when order gets filled:
- close[ordertype] = order type
- close[price] = price
- close[price2] = secondary price
Cancel open order
Params:
- txid = transaction id
Get account balance
(This API call accepts no parameters)
Example
iex(1)> KrakenApi.get_account_balance()
{:ok,
%{"BCH" => "...", "XETH" => "...", "XLTC" => "...",
"XXBT" => "...", "XZEC" => "...", "ZEUR" => "..."}}
Get asset info.
Params:
info = info to retrieve (optional):
- info = all info (default)
aclass = asset class (optional):
- currency (default)
- asset = comma delimited list of assets to get info on (optional. default = all for given asset class)
Example
iex(1)> KrakenApi.get_asset_info()
{:ok,
%{"BCH" => %{"aclass" => "currency", "altname" => "BCH", "decimals" => 10,
"display_decimals" => 5},
...
}
iex(1)> KrakenApi.get_asset_info(%{asset: "BCH,XBT"})
{:ok,
%{"BCH" => %{"aclass" => "currency", "altname" => "BCH", "decimals" => 10,
"display_decimals" => 5},
"XXBT" => %{"aclass" => "currency", "altname" => "XBT", "decimals" => 10,
"display_decimals" => 5}}}
Get closed orders
Params:
- trades = whether or not to include trades in output (optional. default = false)
- userref = restrict results to given user reference id (optional)
- start = starting unix timestamp or order tx id of results (optional. exclusive)
- end = ending unix timestamp or order tx id of results (optional. inclusive)
- ofs = result offset
closetime = which time to use (optional)
- open
- close
- both (default)
Example
iex(8)> KrakenApi.get_closed_orders(%{start: 1507204548})
{:ok,
%{"closed" => ...},
...}
Get ledgers info
Params:
aclass = asset class (optional):
- currency (default)
- asset = comma delimited list of assets to restrict output to (optional. default = all)
type = type of ledger to retrieve (optional):
- all (default)
- deposit
- withdrawal
- trade
- margin
- start = starting unix timestamp or ledger id of results (optional. exclusive)
- end = ending unix timestamp or ledger id of results (optional. inclusive)
- ofs = result offset
Example
ex(1)> KrakenApi.get_ledgers_info(%{type: "deposit"})
{:ok,
%{"count" => 125,
"ledger" => %{"..." => %{"aclass" => "currency",
"amount" => "...", "asset" => "XETH",
"balance" => "...", "fee" => "...",
"refid" => "...", "time" => ...,
"type" => "deposit"},
...
}}}
Get OHLC data
Params:
- pair = asset pair to get OHLC data for
- interval = time frame interval in minutes (optional): 1 (default), 5, 15, 30, 60, 240, 1440, 10080, 21600
- since = return committed OHLC data since given id (optional. exclusive)
Get open orders
Params:
- trades = whether or not to include trades in output (optional. default = false)
- userref = restrict results to given user reference id (optional)
Get open positions
Params:
- txid = comma delimited list of transaction ids to restrict output to
- docalcs = whether or not to include profit/loss calculations (optional. default = false)
Get order book
Params:
- pair = asset pair to get market depth for
- count = maximum number of asks/bids (optional)
Get recent spread data
Params:
- pair = asset pair to get spread data for
- since = return spread data since given id (optional. inclusive)
Get recent trades
Params:
- pair = asset pair to get spread data for
- since = return spread data since given id (optional. inclusive)
Get the server time.
(This API call accepts no parameters)
Example
iex(1)> KrakenApi.get_server_time()
{:ok, %{"rfc1123" => "Thu, 5 Oct 17 14:03:21 +0000", "unixtime" => 1507212201}}
Get ticker information
Param:
- pair = comma delimited list of asset pairs to get info on
Get tradable asset pairs
Params:
info = info to retrieve (optional):
- info = all info (default)
- leverage = leverage info
- fees = fees schedule
- margin = margin info
- pair = comma delimited list of asset pairs to get info on (optional. default = all)
Get trade balance
Params:
aclass = asset class (optional):
- currency (default)
- asset = base asset used to determine balance (default = ZUSD)
Get trade volume
Params:
- pair = comma delimited list of asset pairs to get fee info on (optional)
- fee-info = whether or not to include fee info in results (optional)
Get trades history
Params:
type = type of trade (optional)
- all = all types (default)
- any position = any position (open or closed)
- closed position = positions that have been closed
- closing position = any trade closing all or part of a position
- no position = non-positional trades
- trades = whether or not to include trades related to position in output (optional. default = false)
- start = starting unix timestamp or trade tx id of results (optional. exclusive)
- end = ending unix timestamp or trade tx id of results (optional. inclusive)
- ofs = result offset
Query ledgers
Params:
- id = comma delimited list of ledger ids to query info about (20 maximum)
Query orders info
Params:
- trades = whether or not to include trades in output (optional. default = false)
- userref = restrict results to given user reference id (optional)
- txid = comma delimited list of transaction ids to query info about (20 maximum)
Query trades info
Params:
- txid = comma delimited list of transaction ids to query info about (20 maximum)
- trades = whether or not to include trades related to position in output (optional. default = false)