get_lsratio {cryptoQuotes} | R Documentation |
Get the long to short ratio of a cryptocurrency pair
Description
Get the long-short ratio for any available_tickers()
from the available_exchanges()
Usage
## long-short ratio
get_lsratio(
ticker,
interval = '1d',
source = 'binance',
from = NULL,
to = NULL,
top = FALSE
)
Arguments
ticker |
A character vector of length 1. See |
interval |
A character vector of length 1. See |
source |
A character-vector of length 1. See |
from |
An optional vector of length 1. Can be |
to |
An optional vector of length 1. Can be |
top |
A logical vector. FALSE by default. If TRUE it returns the top traders Long-Short ratios. |
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,
long (numeric) - the share of longs
short (numeric) - the share of shorts
ls_ratio (numeric) - the ratio of longs to shorts
Note
Available exchanges
See available_exchanges()
with for available exchanges.
Limited return values
Binance only supports data for the last 30 days. Use other exchanges if you need beyond that.
Author(s)
Jonas Cuzulan Hirani
See Also
Other get-function:
get_fgindex()
,
get_fundingrate()
,
get_openinterest()
,
get_quote()
Examples
## Not run:
# Example on loading
# long-short ratio
# for the last days
# on the 15 minute candle
# wrapped in try to avoid
# failure on Github
# 1) long-short ratio
# on BTCUSDT pair
ls_ratio <- cryptoQuotes::get_lsratio(
ticker = 'BTCUSDT',
interval = '15m',
from = Sys.Date() - 1,
to = Sys.Date()
)
# 2) BTCSDT in same period
# as the long-short ratio;
BTC <- cryptoQuotes::get_quote(
ticker = 'BTCUSDT',
futures = TRUE,
interval = '15m',
from = Sys.Date() - 1,
to = Sys.Date()
)
# 3) plot BTCUSDT-pair
# with long-short ratio
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::kline(),
sub = list(
cryptoQuotes::lsr(ratio = ls_ratio),
cryptoQuotes::volume()
),
indicator = list(
cryptoQuotes::bollinger_bands()
)
)
## End(Not run)
# end of scrtipt;