CNN Fear & Greed Index

io.github.wildsurfer由 GitHub 账号 wildsurfer 发布v2.2.0更新于 Oct 24, 2026

CNN's Fear & Greed index for the US stock market: score, rating, indicators and daily history.

已验证STDIO仅桌面金融数据与分析

概览

AI 生成的概览

让助手获取 CNN 美国股市恐惧与贪婪指数,包括当前分数、评级、各分项指标和每日历史数据。

可以做什么
以 stdio 方式在本地运行 MCP 服务器,只暴露一个工具 get_fear_and_greed,可选参数 include_history。它返回当前 0-100 的分数与评级、前收盘、一周前、一月前和一年前的数值、约一年的每日历史,以及七个分项指标(市场动能、股价强度、股价广度、看跌/看涨期权、市场波动率、垃圾债需求、避险需求),每项都带有自己的分数、评级和原始数值序列。同一 Go 模块还提供命令行工具和库。
适用场景
适合助手需要当前或历史美国市场情绪读数时使用,例如总结市场情绪、把今天的分数与过去时段对比,或查看哪些分项指标在推动指数。它是只读数据源,不是交易或分析引擎。
运行要求
需要本地运行环境:以 mcp 参数启动 cnnfag 可执行文件(可通过 Go 安装,或使用已发布的容器镜像)。MCP 客户端必须能找到该可执行文件,若未继承 PATH 可能需要填写完整路径。需要访问 CNN 数据端点的出站网络;未声明账号、API 密钥或环境变量。
安装前请注意
数据来自 CNN 未公开文档的端点,程序会带上类似浏览器的 User-Agent 和 Referer 请求头;该端点随时可能变更或消失。本项目与 CNN 无关联也未获其认可,MIT 许可证只覆盖代码,CNN 条款限制对该数据的商业利用,合规由使用者自行负责。该服务器只读取数据,不会写入、发送或删除任何内容。

安装

在 SourceWeft 中

  1. 打开 控制台中的 CNN Fear & Greed Index,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

cnn-fear-and-greed-parse

[Go Reference] [CI] [Coverage Status] [License: MIT] [Glama score]

Go package for CNN's Fear & Greed Index, a 0–100 gauge of US stock market sentiment. It returns the current score and rating, the values for the previous close, week, month and year, about a year of daily history, and the seven component indicators (market momentum, stock price strength, stock price breadth, put/call options, market volatility, junk bond demand, safe haven demand), each with its own score, rating and history of raw values. The module also ships a CLI and an MCP server, and has no dependencies outside the Go standard library.

Install

go get github.com/wildsurfer/cnn-fear-and-greed-parse/v2

Usage

go
package main
import (	"context"	"fmt"
	cnnfag "github.com/wildsurfer/cnn-fear-and-greed-parse/v2")
func main() {	result, err := cnnfag.Get(context.Background())	if err != nil {		panic(err)	}
	fmt.Printf("Now: %.0f (%s)\n", result.Score, result.Rating)	fmt.Printf("One year ago: %.0f\n", result.OneYearAgo)	fmt.Printf("History: %d daily points since %s\n",		len(result.History), result.History[0].Date.Format("2006-01-02"))	fmt.Printf("VIX indicator: %.0f (%s)\n",		result.MarketVolatility.Score, result.MarketVolatility.Rating)}

Output:

Now: 64 (greed)One year ago: 58History: 250 daily points since 2025-08-11VIX indicator: 50 (neutral)

An Indicator's History holds the raw underlying series (the S&P 500 level for momentum, the VIX level for volatility, ratios and spreads for the rest), and its Score is CNN's 0–100 normalization. To use your own http.Client (timeout, proxy), replace cnnfag.HTTPClient.

CLI

For cron jobs and shell pipelines, without writing Go:

go install github.com/wildsurfer/cnn-fear-and-greed-parse/v2/cmd/cnnfag@latest
$ cnnfag64 (greed) as of 2026-08-11T00:00:00Zprevious close 64 · week ago 60 · month ago 47 · year ago 58
$ cnnfag -json | jq .score64.3714285714286

-json prints the full result, including the daily history. -timeout changes the request timeout (default 15s).

MCP server

cnnfag mcp runs a Model Context Protocol server over stdio, so AI assistants can query the index. It exposes one tool, get_fear_and_greed, with an optional include_history argument. Configuration for MCP clients:

json
{  "mcpServers": {    "cnnfag": {      "command": "cnnfag",      "args": ["mcp"]    }  }}

The client must be able to find the binary: use the full path (usually ~/go/bin/cnnfag) if your MCP client does not inherit your shell's PATH. Like the rest of the module, the server is built on the standard library only.

The server is also published to the MCP Registry as io.github.wildsurfer/cnnfag, with a container image at ghcr.io/wildsurfer/cnnfag for clients that prefer Docker over a local binary.

How it works

CNN does not offer a documented public API. This package requests the JSON endpoint that the Fear & Greed page itself uses:

https://production.dataviz.cnn.io/index/fearandgreed/graphdata

The endpoint rejects requests that do not look like they come from a browser, so the package sends browser-like User-Agent and Referer headers. This is the same data source used by the known wrappers in other languages.

A scheduled CI job runs the test suite against the real endpoint once a week, so a change on CNN's side is detected within days.

Migrating from v1

v2 is a full rewrite: CNN removed the HTML page that v1 parsed, so v1 stopped working and its data model no longer matches what CNN publishes. Update the import path first:

go
import cnnfag "github.com/wildsurfer/cnn-fear-and-greed-parse/v2"

Then adjust the calls:

v1v2
cnnfag.Parse()cnnfag.Get(ctx), takes a context.Context
Result.Now.Value (int)Result.Score (float64)
Result.Now.TextResult.Rating
Result.PreviousClose.Value (int)Result.PreviousClose (float64)
Result.OneWeekAgo.Value, .OneMonthAgo.Value, .OneYearAgo.Valuesame field names, now plain float64
Result.PreviousClose.Text and other past-period labelsremoved; CNN's API has no labels for past periods, but every History point carries a rating
Result.LastUpdateDateResult.Timestamp, now an exact time from CNN instead of a parsed guess
Result.ImageURL, Result.GetImageBytes()removed; the needle image no longer exists
ErrHTTPNon200ErrUnexpectedStatus, check with errors.Is
ErrEmptyFieldErrEmptyResult
ErrImgLoadNon200, ErrReadingBytesremoved with the image API
—Result.History is new: about a year of daily scores

Scores changed from rounded integers to the exact floats CNN serves, so 44 in v1 corresponds to something like 43.71 in v2. Round with %.0f or math.Round if you need the old look.

Project history

v1 (2021) parsed the HTML of money.cnn.com/data/fear-and-greed with goquery and could also download the index needle image. CNN removed that page, which broke parsing, and the image no longer exists. v2 (2026) is a rewrite on the JSON endpoint with a smaller API, historical data and zero dependencies. The last v1 release is tagged v1.2.0.

Data disclaimer

This package is not affiliated with or endorsed by CNN. The Fear & Greed Index and its values belong to CNN (Warner Bros. Discovery). The MIT license covers only the code in this repository and gives you no rights to CNN's data. CNN's Terms of Use permit personal use of site content and restrict commercial exploitation. If you use this data in a product, compliance is your responsibility, and the endpoint can change or disappear at any time.

License

MIT

来源:README.md,提交 e1955e7

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v2.2.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分