Python wrapper for CNN's Fear & Greed Index.
Fetches CNN's website, parses the index value and returns the data as a three-element tuple.
pip install fear-and-greed
import fear_and_greed
fear_and_greed.get()
Returns a three-element namedtuple with (a) the current value of the Fear & Greed Index, (b) a description of the category into which the index value falls (from "Extreme Fear" to "Extreme Greed") and (c) the timestamp at which the index value was last updated on CNN's website. Example:
FearGreedIndex(
value=31.4266,
description='fear',
last_update=datetime.datetime(2022, 4, 25, 16, 51, 9, 254000, tzinfo=datetime.timezone.utc),
)
historical_data = fear_and_greed.historical()
The historical function provides a list of historical Fear & Greed Index values, each with its corresponding description and timestamp.
[
FearGreedIndex(
value=80.0,
description='extreme greed',
last_update=datetime.datetime(2022, 4, 20, 0, 0, 0, tzinfo=datetime.timezone.utc)
),
FearGreedIndex(
value=60.5,
description='greed',
last_update=datetime.datetime(2022, 4, 21, 0, 0, 0, tzinfo=datetime.timezone.utc)
)
]
...
- Fetch the current Fear & Greed Index value along with its description and timestamp.
- Retrieve historical Fear & Greed Index data to analyze trends.
- Uses locally cached requests to CNN's website for 1 minute to minimize network usage.