get_quote {cryptoQuotes} | R Documentation |
Get the Open, High, Low, Close and Volume data on a cryptocurrency pair
Description
Get a quote on a cryptocurrency pair from the available_exchanges()
in various available_intervals()
for any actively traded available_tickers()
.
Usage
## get OHLC-V
get_quote(
ticker,
source = 'binance',
futures = TRUE,
interval = '1d',
from = NULL,
to = NULL
)
Arguments
ticker |
An character-vector of length 1. See |
source |
A character-vector of length 1. |
futures |
A logical-vector of length 1. TRUE by default. Returns futures market if TRUE, spot market otherwise. |
interval |
A character-vector of length 1. |
from |
An optional character, date or POSIXct vector of length 1. NULL by default. |
to |
An optional character, date or POSIXct vector of length 1. NULL by default. |
Details
On time-zones and dates
Values passed to from
or to
must be coercible by as.Date()
, or as.POSIXct()
, with a format of either "%Y-%m-%d"
or "%Y-%m-%d %H:%M:%S"
. By default
all dates are passed and returned with Sys.timezone()
.
On returns
If only from
is provided 200 pips are returned up to Sys.time()
. If only to
is provided 200 pips up to the specified date
is returned.
Value
An xts-object containing,
open (numeric): the opening price
close (numeric): the closing price
high (numeric): the highest price
low (numeric): the lowest price
volume (numeric): the trading volume
Author(s)
Serkan Korkmaz
See Also
Other get-function:
get_fgindex()
,
get_fundingrate()
,
get_lsratio()
,
get_openinterest()
Examples
## Not run:
# script: scr_getQuote
# date: 2024-02-29
# author: Serkan Korkmaz, serkor1@duck.com
# objective: Demonstrate the basic
# usage of the get_quote-function
# script start;
# 1) Load BTC spot
# from Kucoin with 30 minute
# intervals
BTC <- cryptoQuotes::get_quote(
ticker = 'BTCUSDT',
source = 'binance',
interval = '30m',
futures = FALSE,
from = Sys.Date() - 1
)
# 2) chart the spot price
# using the chart
# function
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::kline(),
indicator = list(
cryptoQuotes::volume(),
cryptoQuotes::bollinger_bands()
)
)
# script end;
## End(Not run)