TheSnoozer / fear-and-greed

Python wrapper for CNN's Fear & Greed Index.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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

Requests to CNN's website are locally cached for 1m.

Test workflow PyPI badge Black badge

About

Python wrapper for CNN's Fear & Greed Index.

License:MIT License


Languages

Language:Python 88.7%Language:Makefile 11.3%