Skip to content

Python wrapper for CNN's Fear & Greed Index.

License

Notifications You must be signed in to change notification settings

Chanda-Holdings/fear-and-greed

 
 

Repository files navigation

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.

Installation

pip install fear-and-greed

Usage example

Fetch Current Fear & Greed Index

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),
 )

Fetch Historical Fear & Greed Data

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)
    )
]
...

Features

  • 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.

Test workflow PyPI badge Black badge

About

Python wrapper for CNN's Fear & Greed Index.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 94.9%
  • Makefile 5.1%