How to get Cryptocurrency prices in R

[This article was first published on R – Predictive Hacks, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Today, we will show how you can easily get the Cryptocurrency Prices using R. We will work with the crypto package.

You can install the crypto package from GitHub:

# Installing via Github
devtools::install_github("jessevent/crypto")
 


How to get the list of the Cryptocurrencies

library(crypto)
library(tidyverse)
list_coins<-crypto_list()

# Print 10 of them
list_coins%>%head(10)%>%select(symbol, name)
 

   symbol name             
 1 BTC    Bitcoin     
 2 ETH    Ethereum    
 3 XRP    XRP         
 4 USDT   Tether      
 5 BCH    Bitcoin Cash
 6 BSV    Bitcoin SV  
 7 LTC    Litecoin    
 8 ADA    Cardano     
 9 LINK   Chainlink   
10 BNB    Binance Coin
 


How to get the Cryptocurrency Prices


Let’s say that I am interested in BTC, XRP, BCH and LTC and I want to get their daily values from 2020-01-01 onwards.

btc<-crypto_history(coin = 'BTC', start_date = "20200101")
xrp<-crypto_history(coin = 'XRP', start_date = "20200101")
bch<-crypto_history(coin = 'BCH', start_date = "20200101")
ltc<-crypto_history(coin = 'LTC', start_date = "20200101")

df<-rbind(btc,xrp,bch,ltc)

df%>%head()
slug symbol name date ranknow open high low close volume market close_ratio spread
bitcoin BTC Bitcoin 1/1/2020 1 7194.89 7254.33 7174.94 7200.17 18565664997 1.306E+11 0.31779821 79.39
bitcoin BTC Bitcoin 1/2/2020 1 7202.55 7212.16 6935.27 6985.47 20802083465 1.267E+11 0.18129943 276.89
bitcoin BTC Bitcoin 1/3/2020 1 6984.43 7413.72 6915 7344.88 28111481032 1.332E+11 0.86196663 498.72
bitcoin BTC Bitcoin 1/4/2020 1 7345.38 7427.39 7309.51 7410.66 18444271275 1.344E+11 0.85807601 117.88
bitcoin BTC Bitcoin 1/5/2020 1 7410.45 7544.5 7400.54 7411.32 19725074095 1.345E+11 0.07488191 143.96
bitcoin BTC Bitcoin 1/6/2020 1 7410.45 7781.87 7409.29 7769.22 23276261598 1.41E+11 0.96604756 372.58

To leave a comment for the author, please follow the link and comment on their blog: R – Predictive Hacks.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)