Predictive Hacks

How to get Cryptocurrency prices in R

cryptocurrency

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()
slugsymbolnamedateranknowopenhighlowclosevolumemarketclose_ratiospread
bitcoinBTCBitcoin1/1/202017194.897254.337174.947200.17185656649971.306E+110.3177982179.39
bitcoinBTCBitcoin1/2/202017202.557212.166935.276985.47208020834651.267E+110.18129943276.89
bitcoinBTCBitcoin1/3/202016984.437413.7269157344.88281114810321.332E+110.86196663498.72
bitcoinBTCBitcoin1/4/202017345.387427.397309.517410.66184442712751.344E+110.85807601117.88
bitcoinBTCBitcoin1/5/202017410.457544.57400.547411.32197250740951.345E+110.07488191143.96
bitcoinBTCBitcoin1/6/202017410.457781.877409.297769.22232762615981.41E+110.96604756372.58

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Leave a Comment

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s