Back to articles
Building a Crypto Fear and Greed Index Tracker with Python

Building a Crypto Fear and Greed Index Tracker with Python

via Dev.to Tutorialagenthustler

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

Read Full Article
2 views

Related Articles