Learn R Programming

cryptoQuotes (version 1.3.4)

fgi: Chart the Fear and Greed Index

Description

[Experimental]

A high-level plotly::plot_ly()-wrapper function. The function adds a subchart with the fear and greed-index.

Usage

fgi(index, ...)

Value

An invisible

plotly::plot_ly()-object.

Arguments

index

A xts::xts()-object. See get_fgindex() for more details.

...

For internal use. Please ignore.

Author

Serkan Korkmaz

Details

Classification

The Fear and Greed Index goes from 0-100, and can be classified as follows,

  • 0-24, Extreme Fear

  • 25-44, Fear

  • 45-55, Neutral

  • 56-75, Greed

  • 76-100, Extreme Greed

About the Fear and Greed Index

The fear and greed index is a market sentiment indicator that measures investor emotions to gauge whether they are generally fearful (indicating potential selling pressure) or greedy (indicating potential buying enthusiasm).

Source

This index is fetched from alternative.me, and can be different from the one provided by coinmarketcap.

See Also

Other chart indicators: add_event(), alma(), bollinger_bands(), chart(), dema(), donchian_channel(), ema(), evwma(), hma(), lsr(), macd(), rsi(), sma(), smi(), volume(), vwap(), wma(), zlema()

Other sentiment indicators: lsr()

Other subchart indicators: add_event(), lsr(), macd(), rsi(), smi(), volume()

Examples

Run this code
if (FALSE) {
  # script start;

  # 1) get the fear and greed index
  # for the last 14 days
  FGIndex <- cryptoQuotes::get_fgindex(
    from = Sys.Date() - 14
  )

  # 2) get the BTC price
  # for the last 14 days
  BTC <- cryptoQuotes::get_quote(
    ticker  = "BTCUSDT",
    source  = "bybit",
    futures = FALSE,
    from    = Sys.Date() - 14
  )

  # 3) chart the daily BTC
  # along side the Fear and
  # Greed Index
  cryptoQuotes::chart(
    ticker = BTC,
    main   = kline(),
    sub    = list(
      fgi(
        FGIndex
      )
    )
  )

  # script end;
}

Run the code above in your browser using DataLab