Profile
Back to NewsBack
GitHub Trending 4 min
Reader Mode
whit3rabbit/fear-greed-data: A historical copy of CNN's Fear and Greed Dataset

whit3rabbit/fear-greed-data: A historical copy of CNN's Fear and Greed Dataset

8 hours ago

Description

Update fear & greed data</a>

The CNN's Fear and Greed website doesn't offer a historical dataset and the datasets that do exist have different values.

I tried to collect the most accurate data I could find combining three different sources into one file. I have included where i found the data and the csv/json.

Canonical dataset

The up-to-date combined file is fear-greed.csv at the repo root.

| Column | Notes | |------------|-------------------------------------------------------| | Date | ISO YYYY-MM-DD | | Fear Greed | Float score 0-100 (CNN era) / integer (pre-2021 era) | | Rating | CNN label (extreme fear, fear, neutral, greed, extreme greed). CNN supplies this directly for 2021-02-01+; for older rows it is computed from the score using CNN's own band cutoffs. |

Coverage:

  • 2011-01-03 through 2021-01-29 is frozen, sourced from datasets/archive/fear-greed-pre-2021.csv (derived from the hackingthemarkets + openstockalert combined file; see history sections below).
  • 2021-02-01 onward is regenerated from the live CNN endpoint on every run.
The previous file fear-greed-2011-2023.csv (M/D/YYYY dates, integer scores) has been replaced by fear-greed.csv.

Automation

A GitHub Actions workflow (.github/workflows/update-data.yml) rebuilds fear-greed.csv Monday through Friday at 23:00 UTC (after US market close) and also supports manual runs via workflow_dispatch. It commits the diff directly to main as github-actions[bot].

Scripts:

To run locally:

uv sync
uv run python scripts/fetch_cnn.py        # -> datasets/cnn_fear_greed.csv + json/cnn_output.json
uv run python scripts/build_combined.py   # -> fear-greed.csv

Dependencies are declared in pyproject.toml and resolved in uv.lock. build_combined.py aborts rather than writing if the combined output would be shorter than the archive, contains duplicate dates, or is more than 7 days stale.

The third-party comparison datasets under datasets/ (openstockalert, hackingthemarkets, alexey-formalmethods, macromicro, archive.org) are historical snapshots and are not refreshed by the workflow.

Datasets

I have pulled multiple datasets and json files from different websites that had historical Fear and Greed data. I've included them in the datasets and json folder.

Openstockalert.com

Hackingthemarkets

alexey-formalmethods

macromicro.me

cnn.com

  • Data from 2021-02-01 is accurate, however before that date data is not accurate.
  • See https://izy.codes/backtest-strategy-fear-and-greed-index-en/
  • See https://github.com/gman4774/fear_and_greed_index github issues
  • Data scraped from https://production.dataviz.cnn.io/index/fearandgreed/graphdata/2021-03-01 (now refreshed automatically; see Automation above)
  • Files: datasets/cnn_fear_greed.csv, json/cnn_output.json

archive.org scrape

Correlation with archive.org data

Higher the coefficent the more correlated with archive.org data:

| DATASET | CORRELATION | |---------------------------------------|--------| | openstockalert_fear_greed_data: | 0.4078 | | alexey-formalmethods_fear_greed_data: | 0.4029 | | macromicro_fear_greed_data: | 0.3437 |

Combining all the Data

The original combined file used hackingthemarkets (2011-2016), openstockalert (2016-2022), and CNN scrape (2022-2023). That file has been superseded by fear-greed.csv (see Canonical dataset above), which uses the same 2011 - 2021-01-29 archive but pulls 2021-02-01 onward directly from the live CNN endpoint.

About the data

CNN's score bands (derived empirically from its own labels in datasets/cnn_fear_greed.csv):

| EMOTION | RANGE | |---------------|--------------| | Extreme Fear | 0 - < 25 | | Fear | 25 - < 45 | | Neutral | 45 - < 55 | | Greed | 55 - < 75 | | Extreme Greed | >= 75 |

Number of total days in each range from 2011-2023

| Range | Days | |---------------|-----------| | Extreme Fear | 503 days | | Fear | 1072 days | | Neutral | 1283 days | | Greed | 240 days | | Extreme Greed | 154 days |

Average number of days in each range from 2011-2023

| Range | Average Duration (Days) | |----------------|-------------------------| | Extreme Fear | 41.6 | | Fear | 56.8 | | Neutral | 16.0 | | Greed | 11.8 | | Extreme Greed | 7.7 |

Chat with me