
Building a Crypto Fear and Greed Index Tracker with Python
The Crypto Fear & Greed Index measures sentiment from 0 (extreme fear) to 100 (extreme greed). Build a tracker combining this with price data for better trading signals. Alternative.me API import requests , statistics from datetime import datetime class FearGreedTracker : def __init__ ( self ): self . fg = " https://api.alternative.me/fng/ " self . cg = " https://api.coingecko.com/api/v3 " def current ( self ): d = requests . get ( f " { self . fg } ?limit=1 " ). json ()[ " data " ][ 0 ] return { " value " : int ( d [ " value " ]), " label " : d [ " value_classification " ]} def history ( self , days = 90 ): return [{ " value " : int ( d [ " value " ]), " label " : d [ " value_classification " ], " date " : datetime . fromtimestamp ( int ( d [ " timestamp " ])). strftime ( " %Y-%m-%d " )} for d in requests . get ( f " { self . fg } ?limit= { days } " ). json ()[ " data " ]] def btc_prices ( self , days = 90 ): r = requests . get ( f " { self . cg } /coins/bitcoin/market_chart " , param
Continue reading on Dev.to Tutorial
Opens in a new tab



![[MM’s] Boot Notes — The Day Zero Blueprint — Test Smarter on Day One](/_next/image?url=https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1368%2F1*AvVpFzkFJBm-xns4niPLAA.png&w=1200&q=75)