Skip to contents
## load library
library(cryptoQuotes)

The main goal of the {cryptoQuotes} is to bridge the gap between R and the cryptocurrency market data. Its a high-level API-client that connects to major cryptocurrency exchanges and their respective public market data endpoints.

In this article we will focus on price and sentiment data made available by the Kraken exchange.

Cryptocurrency market data

In this section we will focus on market data from the last 24 hours, on the hourly chart.

Open, Highl Low, Close and Volume (OHLC-V) data

To get OHLC-V data the get_quote()-function is the go-to function,

## Get the
## SPOT price of 
## Bitcoin on the hourly
BTC <- get_quote(
  ticker   = "BTCUSD",
  source   = "kraken",
  futures  = FALSE,
  interval = "1h",
  from     = Sys.Date() - 1
)
Hourly Bitcoin OHLC-V data
index open high low close volume
2025-09-18 116469.1 116484.1 116201.1 116322 75.291
2025-09-18 01:00:00 116322 116906.2 116321.9 116724.8 21.872
2025-09-18 02:00:00 116724.8 116955 116537.5 116955 14.817
2025-09-18 03:00:00 116955 117900 116955 117600.5 365.281
2025-09-18 04:00:00 117600.5 117734 117267.6 117562.4 26.117
2025-09-18 05:00:00 117562.5 117562.5 117298.3 117298.4 11.665

Sentiment data

One sentiment indicator for Bitcoin is the long-short ratio, which can be retrieved using get_lsratio()-function,

## Get the
## long-short ratio of 
## Bitcoin on the hourly
LS_BTC <- get_lsratio(
  ticker   = "PF_XBTUSD",
  source   = "kraken",
  interval = "1h",
  from     = Sys.Date() - 1
)
Hourly Long-Short Ratio on Bitcoin
index long short ls_ratio
2025-09-18 0.727 0.273 2.668
2025-09-18 01:00:00 0.725 0.275 2.632
2025-09-18 02:00:00 0.725 0.275 2.636
2025-09-18 03:00:00 0.727 0.273 2.663
2025-09-18 04:00:00 0.727 0.273 2.658
2025-09-18 05:00:00 0.726 0.274 2.655

Limitations

There is a limit to the amount of market data that can be extracted in one call. The Kraken exchange, for example, has a limit on 5000 rows of data per call in the futures market,

## Get the SPOT
## market for over 
## 2000 rows
tryCatch(
  get_quote(
    ticker   = "PF_XBTUSD",
    source   = "kraken",
    futures  = TRUE,
    interval = "5m",
    from     = Sys.Date() - 25,
    to       = Sys.Date()
  ),
  error = function(error) {
    
    error
    
  }
)
#>                       open   high    low  close  volume
#> 2025-08-24 00:00:00 115466 115466 115384 115391  5.0063
#> 2025-08-24 00:05:00 115391 115391 115352 115383  1.0866
#> 2025-08-24 00:10:00 115383 115410 115379 115410  1.5896
#> 2025-08-24 00:15:00 115410 115430 115379 115414  2.9230
#> 2025-08-24 00:20:00 115414 115432 115409 115432  0.5284
#> 2025-08-24 00:25:00 115432 115452 115432 115452  0.0917
#> 2025-08-24 00:30:00 115452 115486 115416 115484 25.5499
#> 2025-08-24 00:35:00 115484 115484 115466 115466  0.1679
#> 2025-08-24 00:40:00 115466 115584 115466 115500 16.8106
#> 2025-08-24 00:45:00 115500 115505 115373 115486 20.7638
#>                 ...                                    
#> 2025-08-30 21:50:00 108581 108611 108578 108611  0.7972
#> 2025-08-30 21:55:00 108611 108662 108611 108647  2.0297
#> 2025-08-30 22:00:00 108647 108647 108542 108557 12.0209
#> 2025-08-30 22:05:00 108557 108568 108491 108528  4.2965
#> 2025-08-30 22:10:00 108528 108550 108520 108550  1.4188
#> 2025-08-30 22:15:00 108550 108589 108547 108556  1.0662
#> 2025-08-30 22:20:00 108556 108568 108537 108537  0.7879
#> 2025-08-30 22:25:00 108537 108590 108537 108587  0.0780
#> 2025-08-30 22:30:00 108587 108587 108533 108538  1.2586
#> 2025-08-30 22:35:00 108538 108595 108538 108594  3.9687

If you need more data than this, you need to do multiple calls. One such solution is the following,

## 1) create date
## sequence
dates <- seq(
  from       = as.POSIXct(Sys.Date()),
  by         = "-5 mins",
  length.out = 10000
)

## 2) split the sequence
## in multiples of 100
## by assigning numbers
## to each indices of 100
idx <- rep(
  x    = 1:2,
  each = 5000
)

## 3) use the idx to split
## the dates into equal parts
split_dates <- split(
  x = dates,
  f = idx
)

## 4) collect all all
## calls in a list
## using lapply
ohlc <- lapply(
  X   = split_dates,
  FUN = function(dates){
    
    Sys.sleep(1)
    
    cryptoQuotes::get_quote(
      ticker   = "PF_XBTUSD",
      source   = "kraken",
      futures  = TRUE,
      interval = "5m",
      from     = min(dates),
      to       = max(dates)
    )
    
  }
)

## 4.1) rbind all
## elements
nrow(
  ohlc <- do.call(
    what = rbind,
    args = ohlc
  )
)
#> [1] 4000

Note: For an indepth analysis of the various limitations and workarounds please see the {cryptoQuotes} wiki on Github