kraken v0.1.1 Kraken.API

API requests client for Kraken exchange.

Link to this section Summary

Functions

Post order by account

Cancel existing unclosed order

Get info about tradable asset pairs

Get account balance

Get account’s closed orders

Get info about tradable asset pairs

Get account’s open orders

Get order book

Get recent trades

Get recent spread data

Get info about tradable asset pairs

Get detailed account balance in some currency

Use this to execute private requests without API wrapper. OTP param is needed in case of 2 Factor Auth

Use this to execute public requests without API wrapper

Get detailed info about order

Link to this section Functions

Link to this function add_order(opts)
add_order(Keyword.t()) :: {:ok, map()} | {:error, Kraken.ApiError}

Post order by account

Options:

  • otp: 2 factor auth code (required if it’s enabled)
  • 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(opts)
cancel_open_order(Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Cancel existing unclosed order

Options:

  • otp: 2 factor auth code (required if it’s enabled)
  • txid: transaction id
Link to this function get_asset_pairs(opts \\ [])
get_asset_pairs(Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Get info about tradable asset pairs

Options:

  • 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_balance(opts \\ [])
get_balance(Keyword.t()) :: {:ok, map()} | {:error, Kraken.ApiError}

Get account balance

Options:

  • otp: 2 factor auth code (required if it’s enabled)
Link to this function get_closed_orders(opts \\ [])
get_closed_orders(Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Get account’s closed orders

Options:

  • otp: 2 factor auth code (required if it’s enabled)
  • 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)
Link to this function get_ohlc(opts)
get_ohlc(Keyword.t()) :: {:ok, map()} | {:error, Kraken.ApiError}

Get info about tradable asset pairs

Options:

  • 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(opts \\ [])
get_open_orders(Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Get account’s open orders

Options:

  • otp: 2 factor auth code (required if it’s enabled)
  • 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_order_book(opts)
get_order_book(Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Get order book

Options:

  • pair: asset pair to get market depth for
  • count: maximum number of asks/bids (optional)
Link to this function get_recent_trades(opts)
get_recent_trades(Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Get recent trades

Options:

  • pair: asset pair to get trade data for
  • since: return trade data since given id (optional. exclusive)
Link to this function get_spread(opts)
get_spread(Keyword.t()) :: {:ok, map()} | {:error, Kraken.ApiError}

Get recent spread data

Options:

  • pair: asset pair to get spread data for
  • since: return spread data since given id (optional. inclusive)
Link to this function get_ticker(opts)
get_ticker(Keyword.t()) :: {:ok, map()} | {:error, Kraken.ApiError}

Get info about tradable asset pairs

Options:

  • pair: comma delimited list of asset pairs to get info on
Link to this function get_trade_balance(opts \\ [])
get_trade_balance(Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Get detailed account balance in some currency

Options:

  • otp: 2 factor auth code (required if it’s enabled)
  • aclass: asset class (optional): currency (default)
  • asset: base asset used to determine balance (default = ZUSD)
Link to this function private_post_request(api_name, data, opts \\ [])
private_post_request(String.t(), Keyword.t(), Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Use this to execute private requests without API wrapper. OTP param is needed in case of 2 Factor Auth.

Link to this function public_get_request(api_name, params, cost \\ 1)
public_get_request(String.t(), Keyword.t(), integer()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Use this to execute public requests without API wrapper

Link to this function query_orders_info(opts \\ [])
query_orders_info(Keyword.t()) ::
  {:ok, map()} |
  {:error, Kraken.ApiError}

Get detailed info about order

Options:

  • otp: 2 factor auth code (required if it’s enabled)
  • 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)