Skip to content

firedintern/meta-fgi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

116 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Fear & Greed Protocol

Real-time crypto market sentiment tracker with casino-style visualization, portfolio management, Telegram bot alerts, historical backtesting, and Hindsight Score analysis

Live Demo License

Features

Real-Time Market Data

  • Fear & Greed Index - Live crypto market sentiment (0-100), updated daily
  • Bitcoin Price Tracker - Real-time BTC price with 24h change percentage
  • 30-Day Historical Chart - Interactive Chart.js line chart with color-coded sentiment points
  • Sentiment Distribution Chart - Donut chart showing how sentiment breaks down across the last 30 days
  • Auto-Refresh - Market data updates every 60 seconds, BTC price every 30 seconds

Casino-Style Interface

  • Slot Machine Visualization - Three-reel emoji-based sentiment display
  • Jackpot Sounds - Musical audio feedback via Web Audio API
  • Animated Spinning Reels - Smooth staggered animations with shake effects
  • Matrix Rain Effect - Toggleable Matrix-style background animation (โœจ button)
  • Win Flash Effects - Visual burst effects for extreme market conditions
  • Emoji Rain - Cascading emoji particles after each spin

Portfolio Management

  • Portfolio Tracker - Input and save your crypto, stablecoin, and cash holdings
  • Smart Allocation Advice - Recommendations based on Fear & Greed Index and your portfolio balance
  • Visual Portfolio Chart - Interactive doughnut chart showing allocation breakdown
  • Persistent Storage - Portfolio data saved locally in browser
  • Real-time Suggestions - Dynamic advice like "Deploy your cash - great entry point!" or "Take profits - you're overexposed!"

Hindsight Score

  • Historical Analysis Modal - Click the ๐Ÿ”ฎ button to open a full breakdown of how Bitcoin has performed after each FGI range
  • 5.5-Year Dataset - Based on 2,000 days of data (May 2020 - Nov 2025), covering multiple full market cycles
  • Three Time Horizons - Forward returns at 7, 14, and 30 days for each sentiment range
  • Win Rate Stats - Sample sizes, win rates, best/worst cases for each range
  • Live-Linked - Auto-updates to reflect the current FGI score whenever you spin or refresh

Key finding (5.5-year data):

FGI Range 30d Avg Return Win Rate
Extreme Fear (0-24) -0.85% 48.4%
Fear (25-44) +4.54% 56.8%
Neutral (45-59) +6.82% 59.6%
Greed (60-79) +3.97% 50.8%
Extreme Greed (80-100) +21.87% 74.8%

Sentiment Intelligence

  • Streak Tracking - Consecutive days in the current sentiment category
  • Historical Records - Longest streak records with dates (e.g., "Record: 15 days in March 2024")
  • Contextual Quotes - Trading wisdom tailored to current market sentiment
  • Sentiment Categories - 5 levels from Extreme Fear to Extreme Greed with emoji indicators

Telegram Bot Alerts

  • Bot: @fgichadbot
  • Subscribe with /start to receive Telegram alerts at extreme FGI levels
  • Unsubscribe with /stop at any time
  • Status check with /status to get the current FGI score
  • Daily cron runs at 4 PM UTC and sends alerts when FGI reaches extreme levels
  • Subscriber data stored in Vercel KV (Redis-compatible key-value store)

Smart Notifications & Sharing

  • Extreme Alerts - Browser notifications for extreme fear/greed levels (score โ‰ค20 or โ‰ฅ80)
  • Degen Advice - Trading suggestions from "๐Ÿ’Ž Accumulate" to "โš ๏ธ Exit Now"
  • Share on X - One-click Twitter/X sharing with custom formatted text

Fully Responsive & Accessible

  • Mobile-Optimized Layout - Touch-friendly with adaptive sizing
  • Keyboard Navigation - Full keyboard support with visible focus indicators
  • ARIA Labels - Screen reader friendly with proper roles and states
  • Performance Optimized - GPU-accelerated animations, throttled matrix effect

Live Demo

fgichad.xyz

Tech Stack

  • Frontend: Vanilla JavaScript (ES6+), HTML5, CSS3
  • Charts: Chart.js 4.4.0 (Line, Doughnut, and Sentiment Distribution charts)
  • Storage: LocalStorage API (portfolio persistence)
  • Bot Storage: Vercel KV (Telegram subscriber list)
  • APIs:
  • Deployment: Vercel (serverless functions + daily cron)
  • Audio: Web Audio API (dynamic jackpot sounds)
  • Animations: CSS3 animations with GPU acceleration
  • Accessibility: ARIA labels, keyboard navigation support
  • Fonts: Comic Sans (degen vibes), Courier New (terminal aesthetic)

How to Use

Basic Usage

  1. Visit fgichad.xyz
  2. Watch the slot machine display current sentiment
  3. Tap/click the slot machine or ๐ŸŽฐ lever to refresh
  4. Enable notifications (๐Ÿ””) for extreme market alerts

Controls

Button Action
โœจ Toggle Matrix background animation
๐Ÿ”” Enable browser notifications for extreme sentiment (โ‰ค20 or โ‰ฅ80)
๐Ÿ’ผ Open portfolio management modal
๐Ÿ”ฎ Open Hindsight Score modal (historical analysis)
Telegram icon Subscribe to Telegram bot alerts
๐ŸŽฐ Spin Refresh all data and spin the slot machine
Share on X Post current sentiment to Twitter/X

Sentiment Guide

Score Status Emoji Degen Advice
0-24 Extreme Fear ๐Ÿ’€ ๐Ÿ’Ž Accumulate
25-44 Fear ๐Ÿ˜ฑ ๐Ÿค” Good Entry
45-59 Neutral ๐Ÿ˜ ๐Ÿ˜ Wait & See
60-79 Greed ๐Ÿ˜ ๐Ÿšจ Take Profits
80-100 Extreme Greed ๐Ÿค‘ โš ๏ธ Exit Now

Using Portfolio Management

  1. Click the ๐Ÿ’ผ Portfolio button in the top-right controls
  2. Enter your holdings:
    • Crypto Holdings ($) - Your total crypto value (BTC, ETH, alts)
    • Stablecoins ($) - USDT, USDC, DAI, etc.
    • Cash/Fiat ($) - Fiat currency ready to deploy
  3. Click Save Portfolio
  4. View your allocation breakdown chart and percentage split
  5. Get real-time advice based on Fear & Greed Index:
    • Extreme Fear + High Cash โ†’ "Deploy your cash - great entry point!"
    • Extreme Greed + High Crypto โ†’ "Take profits - you're overexposed!"
    • Fear + Low Crypto โ†’ "Good time to increase crypto allocation"
    • Greed + High Crypto โ†’ "Consider taking some profits"
    • Balanced โ†’ "Your allocation looks good"

Portfolio data is saved locally in your browser and persists across sessions.

Understanding Streak Tracking

The app tracks consecutive days the market stays in the same sentiment category:

  • Current Streak - How many days in a row (e.g., "Day 5 of Extreme Fear")
  • Historical Records - The longest streak ever recorded for that category
  • Record Dates - When records were set (e.g., "Record: 15 days in Mar 2024")
  • Record Alerts - Highlights when you're breaking a record

Example displays:

  • Day 1 of Extreme Fear (Just started!)
  • Day 7 of Greed (Above avg! Typical: 4.2 days | Record: 12 days in Jan 2024)
  • Day 15 of Extreme Fear RECORD BROKEN! (Previous: 12 days in Nov 2023)

Running Locally

# Clone the repository
git clone https://github.com/firedintern/meta-fgi.git
cd meta-fgi

# Install dependencies (only needed for backtest scripts)
npm install

# Open in browser โ€” no build step needed
open index.html

Running the Backtest

node scripts/backtest-hindsight-score.js

This fetches 5.5 years of FGI + BTC price data and outputs data/backtest-results-5.5years.json.

Project Structure

meta-fgi/
โ”œโ”€โ”€ index.html                    # Production website (DO NOT modify without approval)
โ”œโ”€โ”€ api/                          # Vercel serverless functions
โ”‚   โ”œโ”€โ”€ fgi.js                    # FGI proxy API
โ”‚   โ”œโ”€โ”€ telegram-webhook.js       # Telegram bot webhook handler
โ”‚   โ”œโ”€โ”€ check-fgi-cron.js         # Daily cron โ€” checks FGI & sends Telegram alerts
โ”‚   โ””โ”€โ”€ admin-subscribers.js      # Admin endpoint for subscriber management
โ”œโ”€โ”€ scripts/                      # Utility & data processing
โ”‚   โ”œโ”€โ”€ backtest-hindsight-score.js  # 5.5-year FGI + BTC backtest
โ”‚   โ”œโ”€โ”€ create-integration.js     # Integration automation
โ”‚   โ”œโ”€โ”€ explain-overlap.js        # Data overlap analysis
โ”‚   โ”œโ”€โ”€ extract-cmc-fgi.js        # CMC data extraction
โ”‚   โ”œโ”€โ”€ playwright.config.js      # Playwright test config
โ”‚   โ”œโ”€โ”€ test-api-limits.js        # API rate limit testing
โ”‚   โ”œโ”€โ”€ test-btc-alternatives.js  # Alternative BTC source testing
โ”‚   โ””โ”€โ”€ test-cmc-api.js           # CMC API testing
โ”œโ”€โ”€ data/                         # Backtest results & cached data
โ”‚   โ”œโ”€โ”€ backtest-results-5.5years.json  # Full 5.5-year backtest output
โ”‚   โ”œโ”€โ”€ backtest-results.json     # 1-year backtest output
โ”‚   โ”œโ”€โ”€ hindsight-data.csv        # Raw CSV data
โ”‚   โ””โ”€โ”€ cmc-page-shared-data.json # CoinMarketCap cached data
โ”œโ”€โ”€ drafts/                       # Experimental HTML versions (not production)
โ”‚   โ”œโ”€โ”€ hindsight-score-demo.html # Standalone Hindsight Score demo
โ”‚   โ”œโ”€โ”€ index-full-integration.html  # Full integration prototype
โ”‚   โ””โ”€โ”€ index-with-hindsight.html # Hindsight integration draft
โ”œโ”€โ”€ docs/                         # Project documentation
โ”‚   โ”œโ”€โ”€ DATA-SOURCES.md           # API & data source details
โ”‚   โ”œโ”€โ”€ BACKTEST-COMPARISON.md    # 1-year vs 5.5-year analysis
โ”‚   โ”œโ”€โ”€ INTEGRATION-SUMMARY.md    # Hindsight Score integration notes
โ”‚   โ””โ”€โ”€ TELEGRAM-SETUP.md         # Telegram bot deployment guide
โ”œโ”€โ”€ .claude/
โ”‚   โ”œโ”€โ”€ commands/                 # Slash command definitions
โ”‚   โ”œโ”€โ”€ skills/                   # Claude Code skill configs
โ”‚   โ”‚   โ””โ”€โ”€ frontend-design.md    # Frontend design skill
โ”‚   โ””โ”€โ”€ agents/                   # Subagent definitions
โ”œโ”€โ”€ .mcp.json                     # MCP server configuration
โ”œโ”€โ”€ CLAUDE.md                     # Claude Code project instructions
โ”œโ”€โ”€ vercel.json                   # Vercel cron + headers config
โ””โ”€โ”€ package.json                  # Node.js dependencies (axios)

External APIs

API Purpose Endpoint Cost
Alternative.me Fear & Greed Index https://api.alternative.me/fng/ Free
CoinGecko Real-time BTC price https://api.coingecko.com/api/v3/ Free
CryptoCompare BTC price history (backtesting) https://min-api.cryptocompare.com/data/v2/histoday Free (100k/mo)
Telegram Bot API User alerts https://api.telegram.org/ Free

Environment Variables

All secrets live in Vercel environment variables only โ€” never committed to the repo.

Variable Purpose
TELEGRAM_BOT_TOKEN From @BotFather
KV_REST_API_URL Vercel KV database URL
KV_REST_API_TOKEN Vercel KV auth token
CRON_SECRET Protects manual cron triggers
ADMIN_SECRET Protects admin endpoints

Claude Code Integration

This repo includes Claude Code configuration for AI-assisted development:

  • CLAUDE.md - Project context and rules for Claude Code sessions
  • .mcp.json - MCP servers (Playwright for UI testing, Context7 for docs, Fetch for APIs)
  • Slash Commands:
    • /design-review - Comprehensive UI/UX design review with Playwright screenshots
    • /code-review - Pragmatic code quality review of branch changes
    • /security-review - Security-focused vulnerability assessment
    • /frontend-design - Create distinctive, production-grade frontend interfaces
  • Subagents:
    • @design-review - Specialized design review agent with Playwright tooling

Telegram Bot Setup

See docs/TELEGRAM-SETUP.md for full deployment instructions.

Quick start:

  1. Message @fgichadbot on Telegram
  2. Send /start to subscribe to extreme FGI alerts
  3. Receive daily alerts when FGI hits extreme levels (โ‰ค25 or โ‰ฅ75)

Customization

Change Matrix Effect Opacity

#matrix-canvas { opacity: 0.15; } /* Desktop */
@media (max-width: 768px) {
  #matrix-canvas { opacity: 0.3; } /* Mobile */
}

Modify Auto-Refresh Intervals

setInterval(fetchData, 60000);      // Fear & Greed data (60 seconds)
setInterval(fetchBTCPrice, 30000);  // Bitcoin price (30 seconds)

Customize Sentiment Emojis & Thresholds

function getSymbolForScore(s){
  if(s<=24)return '๐Ÿ’€';  // Extreme Fear: 0-24
  if(s<=44)return '๐Ÿ˜ฑ';  // Fear: 25-44
  if(s<=59)return '๐Ÿ˜';  // Neutral: 45-59
  if(s<=79)return '๐Ÿ˜';  // Greed: 60-79
  return '๐Ÿค‘';           // Extreme Greed: 80-100
}

Customize Portfolio Advice Thresholds

// Extreme Fear + High Cash (cryptoRatio < 30%)
if (fgiScore < 25 && cryptoRatio < 0.3) {
  return { text: "Deploy your cash - great entry point!", color: "#44ff88" };
}

// Extreme Greed + High Crypto (cryptoRatio > 70%)
if (fgiScore > 79 && cryptoRatio > 0.7) {
  return { text: "Take profits - you're overexposed!", color: "#ff4444" };
}

Contributing

Contributions are welcome! Feel free to:

  • Report bugs or issues
  • Suggest new features or improvements
  • Submit pull requests
  • Share feedback on UX/UI

License

MIT License - feel free to use this project for anything!

Credits

Links


Disclaimer: This tool is for entertainment and informational purposes only. Portfolio tracking and advice features are educational tools and do not constitute financial advice. Always do your own research (DYOR) and consult with financial professionals before making investment decisions.

About

Meta Fear & Greed Index

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors