kraken_api v0.1.0 KrakenApi View Source

Documentation of all the API calls and the corresponding parameters.

Link to this section Summary

Link to this section Functions

Link to this function add_standard_order(params \\ %{}) View Source

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
Link to this function cancel_open_order(params \\ %{}) View Source

Cancel open order

Params:

  • txid = transaction id
Link to this function get_account_balance(params \\ %{}) View Source

Get account balance

(This API call accepts no parameters)

Example

iex(1)> KrakenApi.get_account_balance()
{:ok,
%{"BCH" => "...", "XETH" => "...", "XLTC" => "...",
 "XXBT" => "...", "XZEC" => "...", "ZEUR" => "..."}}
Link to this function get_asset_info(params \\ %{}) View Source

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}}}
Link to this function get_closed_orders(params \\ %{}) View Source

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" => ...},
  ...}
Link to this function get_ledgers_info(params \\ %{}) View Source

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"},
      ...
     }}}
Link to this function get_ohlc_data(params \\ %{}) View Source

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)
Link to this function get_open_orders(params \\ %{}) View Source

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)
Link to this function get_open_positions(params \\ %{}) View Source

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)
Link to this function get_order_book(params \\ %{}) View Source

Get order book

Params:

  • pair = asset pair to get market depth for
  • count = maximum number of asks/bids (optional)
Link to this function get_recent_spread_data(params \\ %{}) View Source

Get recent spread data

Params:

  • pair = asset pair to get spread data for
  • since = return spread data since given id (optional. inclusive)
Link to this function get_recent_trades(params \\ %{}) View Source

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}}
Link to this function get_ticker_information(params \\ %{}) View Source

Get ticker information

Param:

  • pair = comma delimited list of asset pairs to get info on
Link to this function get_tradable_asset_pairs(params \\ %{}) View Source

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)
Link to this function get_trade_balance(params \\ %{}) View Source

Get trade balance

Params:

  • aclass = asset class (optional):

    • currency (default)
  • asset = base asset used to determine balance (default = ZUSD)
Link to this function get_trade_volume(params \\ %{}) View Source

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)
Link to this function get_trades_history(params \\ %{}) View Source

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
Link to this function query_ledgers(params \\ %{}) View Source

Query ledgers

Params:

  • id = comma delimited list of ledger ids to query info about (20 maximum)
Link to this function query_orders_info(params \\ %{}) View Source

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)
Link to this function query_trades_info(params \\ %{}) View Source

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)