Skip to contents

[Experimental]

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)

Usage

addFGIndex(chart, FGI)

Arguments

chart

a kline() or ohlc() chart

FGI

The Fear and Greed Index created by getFGIndex()

Value

Invisbly returns a plotly object.

Details

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

  • 0-24, Extreme Fear

  • 25-44, Fear

  • 45-55, Neutral

  • 56-75, Greed

  • 76-100, Extreme Greed

See also

Other chart indicators: addBBands(), addEvents(), addLSRatio(), addMACD(), addMA(), addRSI(), addVolume(), chart()

Examples

# script: Fear and Greed Index
# date: 2023-12-26
# author: Serkan Korkmaz, serkor1@duck.com
# objective: Retrieve and Plot the
# index
# script start;

# 1) get the fear and greed index
# over time
FGI <- try(
  cryptoQuotes::getFGIndex()
)

# 2) get BTCUSDT-pair on
# daily
BTCUSDT <- try(
  cryptoQuotes::getQuote(
    ticker = 'BTCUSDT',
    interval = '1d',
    futures = FALSE
  )
)

# 3) chart the klines
# of BTCUSDT with
# the Fear and Greed Index
if (!inherits(BTCUSDT, 'try-error') & !inherits(FGI, 'try-error')) {

  cryptoQuotes::chart(
    chart = cryptoQuotes::kline(
      BTCUSDT
    ) %>% cryptoQuotes::addFGIndex(
      FGI = FGI
    ),
    slider = FALSE
  )

}
# script end;