## load library
library(cryptoQuotes)
By default
all data from the get_*
-family
of functions is returned with Sys.timezone()
and, if not
specified otherwise, all dates
passed into the
from
and to
parameters are assumed to be
Sys.timezone()
too.
NOTE: As the {pkgdown}-documentation gets built on Github-servers we manually specify the timezone of the
from
andto
parameters.
In this article we will demonstrate the time zone aspect of {cryptoQuotes}.
Open, High, Low, Close and Volume (OHLC-V) with CET
Assume that you are interested in the hourly Bitcoin
price action from yesterday between 16.00 and 18.00 central European
time (CET). We start the example by defining the from
and to
parameters,
# define from
# and to
from <- as.POSIXct(
x = paste(
Sys.Date() - 1, "16:00:00"
),
tz = "CET"
)
to <- as.POSIXct(
x = paste(
Sys.Date() - 1, "18:00:00"
),
tz = "CET"
)
OHLC-V
As the time zone on Github servers are CET
, the
returned OHLC-V data is UTC
as demonstrated below,
## Get hourly
## BTC between
## 16:00 and 18:00 from
## yesterday
xts::tzone(
BTC <- get_quote(
ticker = "BTCUSD",
source = "kraken",
interval = "1h",
futures = FALSE,
from = from,
to = to
)
)
#> [1] "UTC"
All time zones can be converted using the
xts::tzone()
-function. Below is an example of converting
the BTC
to CET
,
## 1) Change time
## zone to CET
BTC_CET <- BTC
xts::tzone(BTC_CET) <- "CET"
Below is table with the original index in UTC
and the converted index in CET
,
Original Index | Converted Index |
---|---|
2024-11-06 15:00:00 | 2024-11-06 16:00:00 |
2024-11-06 16:00:00 | 2024-11-06 17:00:00 |
2024-11-06 17:00:00 | 2024-11-06 18:00:00 |