Skip to contents

[Stable]

Get the long-short ratio for any available_tickers() from the available_exchanges()

Usage

get_lsratio(
   ticker,
   interval = '1d',
   source   = 'binance',
   from     = NULL,
   to       = NULL,
   top      = FALSE
)

Arguments

ticker

A character-vector of length 1. See available_tickers() for available tickers.

interval

A character-vector of length 1. 1d by default. See available_intervals() for available intervals.

source

A character-vector of length 1. binance by default. See available_exchanges() for available exchanges.

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.

top

A logical vector. FALSE by default. If TRUE it returns the top traders Long-Short ratios.

Value

An xts::xts-object containing,

index

<POSIXct> the time-index

long

<numeric> the share of longs

short

<numeric> the share of shorts

ls_ratio

<numeric> the ratio of longs to shorts

Sample output

#>                       long  short  ls_ratio
#> 2024-05-12 02:00:00 0.6930 0.3070 2.2573290
#> 2024-05-13 02:00:00 0.6637 0.3363 1.9735355
#> 2024-05-14 02:00:00 0.5555 0.4445 1.2497188
#> 2024-05-15 02:00:00 0.6580 0.3420 1.9239766
#> 2024-05-16 02:00:00 0.4868 0.5132 0.9485581
#> 2024-05-17 02:00:00 0.5102 0.4898 1.0416497

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.

See also

Other get-functions: get_fgindex(), get_fundingrate(), get_openinterest(), get_quote()

Author

Jonas Cuzulan Hirani

Examples

if (FALSE) { # \dontrun{
  # script start;

  LS_BTC <- cryptoQuotes::get_lsratio(
    ticker   = 'BTCUSDT',
    interval = '15m',
    from     = Sys.Date() - 1,
    to       = Sys.Date()
  )

  # end of scrtipt;
} # }