Skip to content

Usecase

Serkan Korkmaz edited this page Mar 23, 2024 · 25 revisions

Cryptocurrency Market Data in R

The main usecase of the cryptoQuotes-package is the available get_-functions. Below is a basic example of retrieving the daily price of Bitcoin.

## 1) get BTC
## on the daily
BTC <- cryptoQuotes::get_quote(
  ticker  = "BTCUSDT",
  source  = "binance",
  futures = FALSE,
  from    = Sys.Date() - 14
)

## 2) get fear and greed 
## index of the general
## cryptocurrency market
fg_index <- cryptoQuotes::get_fgindex(
  from = Sys.Date() - 14
)

All the returned objects are xts-objects.

Charting

quantmod::chartSeries(
  x = BTC
)
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo

Clone this wiki locally