knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(krakenR)

Introduction

This package interfaces with the kraken API. Currently only for the the GET functions and not all are implemented. It is a work in progress.

Get asset information

Interogate the API for information on the existing assets. Output returned as a list with two elements: error and result. The error element is empty if no error occured. The result element is empty if an error occured. Currently default settings so returns information on all assets:

ast_inf <- get_asset_info()

ast_inf$error

ast_inf$result[[1]]

Get OHLC data

Get market history OHLC data for a specified asset pair. Time frame interval is specifed in minutes: 1 (default), 5, 15, 30, 60, 240, 1440, 10080, 21600. Since can also be provided in Unix long form. Output returned as a list with two elements: error and result. The error element is empty if no error occured. The result element is empty if an error occured. Result contains two elements: the returned OHLC data and the 'last' date in the data set. The default since is 0 (earliest). Data returned:
time; open; high; low; close; vwap; volume; count

ohlc <- get_ohlc_data(pair = "BCHEUR", interval = 30, since = 0)

ohlc$error

head(ohlc$result$BCHEUR)

ohlc$result$last

Get order book

Return the current bid and ask orders for a specific asset. Output returned as a list with two elements: error and result. The error element is empty if no error occured. The result element is empty if an error occured. Result contains two elements: asks; bids. Optional to pass 'count', the maximum number of asks/bids (not implemented). Data returned as:
price; volume; timestamp

ord <- get_order_book("BCHEUR")

ord$error

head(ord$result$BCHEUR$asks)

head(ord$result$BCHEUR$bids)

Get recent spread data

Returns the recent spread data for a specified asset from a specified since. Output returned as a list with two elements: error and result. The error element is empty if no error occured. The result element is empty if an error occured. Result contains two elements: the spread entries for the asset; last, the id to be used as since when polling for new spread data. Data returned as: time; bid; ask

sprd <- get_recent_spread("BCHEUR", since = "1530876860")

sprd$error

head(sprd$result$BCHEUR)

sprd$result$last

Get recent trades

Returns the recent trades for a specified asset from a specified since (default is zero). Output returned as a list with two elements: error and result. The error element is empty if no error occured. The result element is empty if an error occured. Result contains two elements: the trade data for the specified asset over the specified period; last, the id to be used as since when polling for new trade data. Data returned as: price; volume; time; buy/sell; market/limit; miscellaneous

trd <- get_recent_trades("BCHEUR", since = "1501605300157840478")

trd$error

head(trd$result$BCHEUR)

trd$result$last

Get server time

Returns a unix timestamp and an RFC 1123 time format. This is to aid in approximating the skew time between server and client.

get_server_time()

Get ticker info

Returns the ticker info for a comma seperated list of assets. Output returned as a list with two elements: error and result. The error element is empty if no error occured. The result element is empty if an error occured. Data returned for each pair:

pair_list <- paste("BCHEUR", "XBTEUR", sep = ",")
tick <- get_ticker_info(pair_list)

tick$error

tick$result$BCHEUR

Get tradeable asset pair

Returns the requested information for a comma seperated list of tradeable asset pairs. Information requested can be: "info": all info (default); "leverage": leverage info; fees: fees schedule; margin: margin info.Output returned as a list with two elements: error and result. The error element is empty if no error occured. The result element is empty if an error occured. Data returned is:

tap <- get_tradable_asset_pair(info = "margin", 
                               pair_list = "BCHEUR, XBTEUR")

tap$error

tap$result$BCHEUR


aushaff/krakenR documentation built on April 6, 2023, 10:16 p.m.