-
Notifications
You must be signed in to change notification settings - Fork 24
Usecase
At the time of writing there are a few other R
packages that extracts
cryptocurrency market data in R
. These include, but not limited to,
the following,
crypto
crypto2
binancer
coinmarketcapr
crypto
is probably the oldest R
library available, and crypto2
is
essentially a fork
of it. binancer
and coinmarketcapr
are similar
to these libraries
. The most notable difference between these are that
binancer
uses data.table
instead of tibble
.
cryptoQuotes
differentiates itself in various ways. cryptoQuotes
uses xts
-objects, and provides a more flexible granularity than, for
example, crypto
and crypto2
which only supports daily prices.
cryptoQuotes
supports all available intervals
ranging from seconds
to months
. binancer
also supports flexible granularity, but is
limited to OHLC-V
-data from Binance
only. cryptoQuotes
supports
sentiment data on top of OHLC-V
-data, not only from Binance
but for
all major cryptocurrency exchanges.
crypto2
advertises itself as being fully research compliant in the
sense that it also extracts prices of cryptocurrencies that are either
de-listed, or dead projects, to avoid survivorship biases in
cryptocurrency research. crypto
and crypto2
uses webcrawlers to
extract the market data, while cryptoQuotes
uses public market data
endpoints.
The cryptoQuotes
library is primarily used for developing and
evaluating trading strategies, and analyzing the cryptocurrency market
in general. It is not limited to major cryptocurrencies as the included
cryptocurrency exchanges includes the likes KuCoin
and BitMart
where
your average dog-themed cryptocurrency project is listed alongside the
various ElonCumCoin-projects.
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 = "bybit",
futures = FALSE,
interval = "1d",
from = Sys.Date() - 100
)
All the returned objects are xts
-objects, with the following format,
index | open | high | low | close | volume |
---|---|---|---|---|---|
2024-05-21 02:00:00 | 71432.80 | 71981.11 | 69153.24 | 70153.00 | 16546.611 |
2024-05-22 02:00:00 | 70153.00 | 70677.47 | 68896.20 | 69163.10 | 15990.402 |
2024-05-23 02:00:00 | 69163.10 | 70096.43 | 66299.22 | 67971.36 | 19022.937 |
2024-05-24 02:00:00 | 67971.36 | 69257.66 | 66611.44 | 68563.06 | 12600.485 |
2024-05-25 02:00:00 | 68563.06 | 69625.00 | 68502.00 | 69292.07 | 5310.579 |
2024-05-26 02:00:00 | 69292.07 | 69318.98 | 68806.35 | 69114.53 | 1385.539 |
## 1) get daily
## Long-Short Ratio of
## BTC on the daily chart
BTC_LSR <- cryptoQuotes::get_lsratio(
ticker = "BTCUSDT",
source = "bybit",
interval = "1d",
from = Sys.Date() - 100
)
index | long | short | ls_ratio |
---|---|---|---|
2024-05-21 02:00:00 | 0.5343 | 0.4657 | 1.147305 |
2024-05-22 02:00:00 | 0.5456 | 0.4544 | 1.200704 |
2024-05-23 02:00:00 | 0.5516 | 0.4484 | 1.230152 |
2024-05-24 02:00:00 | 0.5677 | 0.4323 | 1.313208 |
2024-05-25 02:00:00 | 0.5569 | 0.4431 | 1.256827 |
2024-05-26 02:00:00 | 0.5636 | 0.4364 | 1.291476 |
NOTE: Github restricts interactivity via GFM, and all the
plotly
-charts are therefore static images. All interactivity is maintained usingscripts
,quarto
and/orRMarkdown
.
The returned market data can be charted and examined as follows,
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::kline(),
indicator = list(
cryptoQuotes::sma(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::sma(n = 21)
),
sub = list(
cryptoQuotes::volume(),
cryptoQuotes::macd(),
cryptoQuotes::lsr(BTC_LSR)
)
)
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::kline(),
indicator = list(
cryptoQuotes::sma(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::sma(n = 21)
),
sub = list(
cryptoQuotes::volume(),
cryptoQuotes::macd(),
cryptoQuotes::lsr(BTC_LSR)
),
options = list(
dark = FALSE
)
)
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::kline(),
indicator = list(
cryptoQuotes::sma(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::sma(n = 21)
),
sub = list(
cryptoQuotes::volume(),
cryptoQuotes::macd(),
cryptoQuotes::lsr(BTC_LSR)
),
options = list(
dark = FALSE,
deficiency = TRUE
)
)
Last updated 2024-07-05