/* FearGreed — Crypto Fear & Greed Index gauge for the marketing site. Mirrors alternative.me/crypto/fear-and-greed-index API shape: { value: 0-100, value_classification: "Greed", timestamp, ... } Swap buildHistory() with a real fetch when ready. */ const FG_LEVELS = [ { max: 24, label: "Extreme fear", color: "#FF5A5F" }, { max: 49, label: "Fear", color: "#FF9F43" }, { max: 54, label: "Neutral", color: "#FFD93D" }, { max: 74, label: "Greed", color: "#A8D957" }, { max: 100, label: "Extreme greed",color: "#00C896" }, ]; const fgLevel = (v) => FG_LEVELS.find(l => v <= l.max) || FG_LEVELS[FG_LEVELS.length - 1]; /* Deterministic 30-day history seeded from current value */ const buildFGHistory = (current) => { let s = 7; const r = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; const out = []; let v = current; for (let i = 29; i >= 0; i--) { out.push(Math.round(Math.max(5, Math.min(95, v)))); v = v + (r() - 0.5) * 14; } return out.reverse(); }; const FearGreedGauge = ({ value, size = 220 }) => { const lvl = fgLevel(value); const cx = size / 2, cy = size * 0.62; const r = size * 0.42; const startA = Math.PI, endA = 0; // half circle, left → right // Convert value 0..100 to angle along the arc const valA = startA + (value / 100) * (endA - startA); // Helper to make arc path between two angles (going clockwise from start) const arc = (a0, a1, color) => { const x0 = cx + r * Math.cos(a0), y0 = cy + r * Math.sin(a0); const x1 = cx + r * Math.cos(a1), y1 = cy + r * Math.sin(a1); const large = Math.abs(a1 - a0) > Math.PI ? 1 : 0; return ; }; // Five colored segments along the arc const segs = [ { from: 0, to: 24, color: "#FF5A5F" }, { from: 24, to: 49, color: "#FF9F43" }, { from: 49, to: 54, color: "#FFD93D" }, { from: 54, to: 74, color: "#A8D957" }, { from: 74, to: 100, color: "#00C896" }, ]; // Needle position const nx = cx + (r - size * 0.02) * Math.cos(valA); const ny = cy + (r - size * 0.02) * Math.sin(valA); return ( {/* track */} {segs.map((s, i) => { const a0 = startA + (s.from / 100) * (endA - startA); const a1 = startA + (s.to / 100) * (endA - startA); return {arc(a0, a1, s.color)}; })} {/* needle */} {/* center value */} {value} out of 100 {/* end labels */} 0 · Fear Greed · 100 ); }; const FGHistoryStrip = ({ values }) => { const w = 460, h = 60, bw = w / values.length - 2; return ( {values.map((v, i) => { const lvl = fgLevel(v); const bh = (v / 100) * (h - 4); return ; })} ); }; const FearGreed = () => { const value = (window.MARKET_GLOBAL && window.MARKET_GLOBAL.fearGreed) || 68; const lvl = fgLevel(value); const history = useMemo(() => buildFGHistory(value), [value]); const yesterday = history[history.length - 2]; const lastWeek = history[history.length - 8]; const lastMonth = history[0]; const cards = [ { label: "Yesterday", value: yesterday }, { label: "Last week", value: lastWeek }, { label: "Last month", value: lastMonth }, ]; return (
Market sentiment

Fear & Greed Index

Aggregated from volatility, momentum, social sentiment, dominance and trends across the market. Updated daily.

{/* Left — gauge */}
{lvl.label}
Updated · {new Date().toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" })}
{/* Right — historical context */}
Last 30 days
30d agotoday
{cards.map(c => { const l = fgLevel(c.value); return (
{c.label}
{c.value} {l.label}
); })}
{/* Legend */}
How to read it
{FG_LEVELS.map((l, i) => { const min = i === 0 ? 0 : FG_LEVELS[i-1].max + 1; return (
{l.label}
{min}–{l.max}
); })}
Source: alternative.me · CryptoPrice.co aggregation
); }; window.FearGreed = FearGreed;