BitBayR
is a simple R public API client to the BitBay crypto-currency exhange.
It consists of 6 functions: bitbay_orderbook
, bitbay_profit
, bitbay_trades
bitbay_trades_from_date
, bitbay_aggregate
and bitbay_ticker
.
Available pairs: all combinations of
BTC
(Bitcoin)
ETC
(Ethereum)
LSK
(Lisk)
LTC
(Litecoin)
GAME
(Game)
DASH
(Dash)
BCC
(Bitcoin cash)
and
PLN
USD
EUR
BTC
They have to be separated by /
.
The function bitbay_orderbook
downloads the actual order book. Its output consists of a list with two dataframes bids
and asks
. Each one contains three
columns Bid
or Ask
, Volume
and Price
. The price is just Bid
or Ask
times the Volume
.
library(BitBayR) order_book <- bitbay_orderbook(pair = "BTC/EUR") head(order_book$bids) head(order_book$asks)
The function bitbay_profit
performs a theoretical/virtual market order. That is, it theoretically sells some specific volume of a specific crypto currency for a specific currency. In the example below one Bitcoin is sold for EUR assuming a prior investment of 5000€ and transaction fees 0.3%.
bitbay_profit(pair = "BTC/EUR", amount = 1, investment = 5000, fee = 0.003)
The function bitbay_trades
can be used to download last n
transactions by specifying the parameter last_trades
. In order to download all historic transactions the parameter last_trades
can be set to "all"
.
last_50_trades <- bitbay_trades(pair = "BTC/EUR", last_trades = 50) tail(last_50_trades)
The function bitbay_trades_from_date
does the same task, however, it downloads all transactions occurred after a specific date. In the example below, all trades within last 3 hours.
last_trades_3h <- bitbay_trades_from_date(pair = "BTC/EUR", date = Sys.time() - 60 * 60 * 3) tail(last_trades_3h)
The function bitbay_aggregate
takes downloaded transactions as input as well as the time interval length (in seconds) and returns a time-series object of class xts
with aggregated transactions.
aggr_data_15min <- bitbay_aggregate(last_50_trades, aggr_time = 15 * 60) tail(aggr_data_15min)
The function bitbay_ticker
can be used to download a ticker for a specific pair.
ticker_BTC_USD <- bitbay_ticker(pair = "BTC/EUR") ticker_BTC_USD
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.