diff --git a/widgets/extensions.yml b/widgets/extensions.yml index 7692e86c..8cc42d66 100644 --- a/widgets/extensions.yml +++ b/widgets/extensions.yml @@ -1,3 +1,8 @@ +- title: Fear & Greed Index + url: https://github.com/yroulin/fear-and-greed-index + description: A visually dynamic Glance widget that tracks real-time cryptocurrency market sentiment using the Crypto Fear & Greed Index API. + author: yroulin + - title: Glance F1 url: https://github.com/SkyAllinott/glance-F1 description: Adds user customization to widget by @abaza738 like local timezones, a track map, and more. diff --git a/widgets/fear-and-greed-index/README.md b/widgets/fear-and-greed-index/README.md new file mode 100644 index 00000000..aeca2b8b --- /dev/null +++ b/widgets/fear-and-greed-index/README.md @@ -0,0 +1,243 @@ +# Crypto Fear & Greed Index + +A [Glance](https://github.com/glanceapp/glance) widget that displays the current **Crypto Fear & Greed Index** โ a widely followed market sentiment indicator that measures whether crypto investors are driven by fear or greed at any given moment. The widget shows a live score from 0 to 100, a color-coded gradient bar with a moving indicator, a sentiment label, an emoji, and a trend arrow comparing today's value against yesterday's. + +No API key, no sign-up, no configuration beyond pasting the YAML. + +--- + +## Preview + + + +--- + +## What is the Fear & Greed Index? + +The Crypto Fear & Greed Index was originally inspired by CNN's Fear & Greed Index for traditional stock markets, adapted for the cryptocurrency ecosystem. It distills complex market signals into a single number between **0** (Extreme Fear) and **100** (Extreme Greed). + +The idea is simple: when the market is driven by **fear**, prices tend to be suppressed and may represent buying opportunities. When the market is driven by **greed**, prices may be overextended and due for a correction. + + +### Index scale + +| Range | Classification | Color | Emoji | What it means | +|---|---|---|---|---| +| 0 โ 25 | **Extreme Fear** | ๐ด Red | ๐ฑ | Investors are very worried. Historically a potential buying opportunity. | +| 26 โ 45 | **Fear** | ๐ Orange | ๐จ | Market sentiment is cautious and uncertain. | +| 46 โ 54 | **Neutral** | ๐ก Yellow | ๐ | Market is balanced between buyers and sellers. | +| 55 โ 75 | **Greed** | ๐ข Green | ๐ | Investors are increasingly confident, FOMO may be building. | +| 76 โ 100 | **Extreme Greed** | ๐ Dark Green | ๐ค | Market may be overheated and due for a correction. | + +--- + +## Features + +- ๐ **Live sentiment score** โ numeric value from 0 to 100 displayed prominently +- ๐จ **Dynamic color coding** โ the score and label change color automatically based on the current classification +- ๐ **Gradient progress bar** โ a full spectrum bar (red โ orange โ yellow โ green) with a white indicator dot that moves to the exact position of the current score +- ๐ฑ โ ๐ค **Emoji + sentiment label** โ human-readable classification shown alongside the score +- **โฒ โผ โ Trend arrow** โ compares today's score against yesterday's so you can see at a glance whether sentiment is improving or deteriorating +- ๐ **Yesterday's value** โ displayed as secondary text beneath the classification +- ๐ **Completely free** โ uses the public [alternative.me](https://alternative.me/crypto/fear-and-greed-index/) API with no authentication required + +--- + +## API + +This widget relies on the **alternative.me Crypto Fear & Greed Index API**, a free and widely used public API that has been running since 2018. + +| Property | Value | +|---|---| +| **Endpoint** | `https://api.alternative.me/fng/?limit=2` | +| **Authentication** | None โ no API key required | +| **Rate limit** | None enforced for normal usage | +| **Update frequency** | Once per day (scores are published daily) | +| **Response format** | JSON | + +The `?limit=2` query parameter tells the API to return the **two most recent daily entries**: today's value (`data.0`) and yesterday's (`data.1`). This is what enables the trend arrow comparison. + +### Example API response + +```json +{ + "name": "Fear and Greed Index", + "data": [ + { + "value": "13", + "value_classification": "Extreme Fear", + "timestamp": "1708905600", + "time_until_update": "74093" + }, + { + "value": "18", + "value_classification": "Extreme Fear", + "timestamp": "1708819200", + "time_until_update": null + } + ], + "metadata": { + "error": null + } +} +``` + +### Fields used by this widget + +| JSON path | Type | Used for | +|---|---|---| +| `data.0.value` | `Int` | Current day's score (0โ100) | +| `data.1.value` | `Int` | Yesterday's score for trend comparison | +| `data.0.value_classification` | `String` | Sentiment label (e.g. `"Extreme Fear"`) | + +--- + +## Installation + +### 1. Open your Glance config file + +Typically located at `glance.yml` or wherever you have your Glance configuration set up (local install or Docker volume mount). + +### 2. Add the widget + +Paste the following block into the `widgets` list of any column on any page: + +```yaml +- type: custom-api + title: Crypto Fear & Greed Index + cache: 1h + url: https://api.alternative.me/fng/?limit=2 + template: | + {{ $value := .JSON.Int "data.0.value" }} + {{ $prev := .JSON.Int "data.1.value" }} + {{ $label := .JSON.String "data.0.value_classification" }} + + {{ $color := "#e74c3c" }} + {{ if ge $value 26 }}{{ $color = "#e67e22" }}{{ end }} + {{ if ge $value 46 }}{{ $color = "#f1c40f" }}{{ end }} + {{ if ge $value 55 }}{{ $color = "#2ecc71" }}{{ end }} + {{ if ge $value 76 }}{{ $color = "#27ae60" }}{{ end }} + + {{ $emoji := "๐ฑ" }} + {{ if ge $value 26 }}{{ $emoji = "๐จ" }}{{ end }} + {{ if ge $value 46 }}{{ $emoji = "๐" }}{{ end }} + {{ if ge $value 76 }}{{ $emoji = "๐ค" }}{{ end }} + + {{ $arrow := "โ" }} + {{ if gt $value $prev }}{{ $arrow = "โฒ" }}{{ end }} + {{ if lt $value $prev }}{{ $arrow = "โผ" }}{{ end }} + +