A simple wrapper for the Alternative.me Crypto Fear and Greed Index API
Project description
Crypto Fear and Greed Index API
A simple Python wrapper for the Alternative.me Crypto Fear and Greed Index API. Get Bitcoin market sentiment data easily with intuitive methods.
Installation
pip install fear-and-greed-crypto
Quick Start
from fear_and_greed import FearAndGreedIndex
# Initialize the client
fng = FearAndGreedIndex()
# Get current index value (0-100)
value = fng.get_current_value()
print(f"Current Fear & Greed Index: {value}")
# Get current classification
sentiment = fng.get_current_classification()
print(f"Market sentiment: {sentiment}") # e.g., "Extreme Fear", "Neutral", "Greed"
# Get complete current data
today = fng.get_current_data()
# Get historical data
from datetime import datetime, timedelta
# Last 7 days
week_data = fng.get_last_n_days(7)
# Data between specific dates
start_date = datetime.now() - timedelta(days=30)
monthly_data = fng.get_historical_data(start_date)
# Calculate averages and medians
week_avg = fng.calculate_average(7)
month_median = fng.calculate_median(30)
Available Methods
Basic Methods
get_current_value()- Get current fear and greed index (0-100)get_current_classification()- Get current market sentiment classificationget_current_data()- Get complete current data including value, classification, and timestamp
Historical Data
get_last_n_days(days: int)- Get data for the last n daysget_historical_data(start_date: datetime, end_date: Optional[datetime] = None)- Get data between dates
Analysis Methods
calculate_average(days: int)- Calculate average index value over specified dayscalculate_median(days: int)- Calculate median index value over specified days
Example Trading Strategy
def should_buy_bitcoin():
fng = FearAndGreedIndex()
fear_level = fng.get_current_value()
# Buy when fear is high (value < 30)
return fear_level < 30
# Example usage
if should_buy_bitcoin():
print("Market shows extreme fear - consider buying!")
See more examples in the examples directory.
Data Attribution
Data provided by Alternative.me. When using this data, please properly acknowledge the source and prominently reference it accordingly.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Author
Rhett Reisman
Email: rhett@rhett.blog
GitHub: https://github.com/rhettre/fear-and-greed-crypto
Disclaimer
This project is not affiliated with, maintained, or endorsed by Alternative.me. Use this software at your own risk. Trading cryptocurrencies carries a risk of financial loss. The developers of this software are not responsible for any financial losses or damages incurred while using this software. Nothing in this software should be seen as an inducement to trade with a particular strategy or as financial advice.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fear_and_greed_crypto-0.1.0.tar.gz.
File metadata
- Download URL: fear_and_greed_crypto-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c9fa59e00fc82d08723291c416f3e6d7d5aeb1064e110cdb67a132b22997752
|
|
| MD5 |
9f8647334c4711d0d7595bc13d7b0048
|
|
| BLAKE2b-256 |
48fc2fd1dae8c32458c2c21677168e2a45a8a33bd76cab7bc14af1709502263c
|
File details
Details for the file fear_and_greed_crypto-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fear_and_greed_crypto-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89ba66f6683dbffdb97c5561d1bf8b5425ebf992e4b77b457b9471a22c9ffc1f
|
|
| MD5 |
aaf3bd8c6bfad246e583b114503fb21c
|
|
| BLAKE2b-256 |
1cc63c297ad216db78a20fbe259006fe354540d831bae1563816a2219e25cbfe
|