Thank you, Singapore. See the photos from our Agentic Patterns workshop at GovTech STACK 2026.

Market Sentiment · Developing a Fear and Greed Index, part 1

1. Methodologies and Sources | Fear and Greed Index

The Fear and Greed Index scores market sentiment from 0 (extreme fear) to 100 (extreme greed) using seven indicators. How CNN builds it, plus an Indonesia version.

RY
Rian Yan
Analytics & Business Intelligence9 min read
1. Methodologies and Sources | Fear and Greed Index

The short answer: the Fear and Greed Index is a 0-100 score of stock market sentiment. CNN builds it from seven indicators: stock price momentum, stock price strength, stock price breadth, the put and call ratio, market volatility (VIX), safe haven demand and junk bond demand. Scores of 0-24 read as extreme fear, 25-44 fear, 45-55 neutral, 56-75 greed and 76-100 extreme greed. CNN publishes the live US reading at CNN Markets. This series rebuilds the index for Indonesian stocks.

Build it with Sectors. The Indonesian version in this series runs on IDX daily prices, trading volume and market capitalization from the Sectors Financial API. Sectors covers IDX and SGX companies through a web app, an API and an MCP server for AI agents, so you can reproduce and track this index yourself.

Understanding the concept of CNN's Fear and Greed Index

The Fear and Greed Index, popularized by CNN (CNN Money), is a tool that measures investor sentiment to help gauge overall market conditions. It's built on the notion that excessive fear often drives asset prices down, while excessive greed can inflate them, potentially creating bubbles. The index combines seven market indicators, each contributing to a composite score ranging from 0 to 100. Lower scores indicate extreme fear, while higher scores reflect extreme greed. This part covers the methodology and data sources. Part 2 shows how the Fear and Greed Index is calculated for each indicator, with Python code.

The seven components of the index cover key areas of the market:

  • Stock Price Momentum: looks at the S&P 500's movement relative to its 125-day average, showing bullish or bearish trends.
  • Stock Price Strength: examines the number of stocks reaching 52-week highs versus lows.
  • Stock Price Breadth: uses the McClellan Volume Summation Index, which compares the volume of rising stocks with the volume of falling ones to show how many stocks take part in a move.
  • Put and Call Ratio: the 5-day average ratio of put options (bets on a fall) to call options (bets on a rise).
  • Market Volatility: represented by the VIX Index, reflects uncertainty or stability in the market.
  • Safe Haven Demand: compares stock performance with that of bonds, a safe haven asset, to indicate risk appetite.
  • Junk Bond Demand: compares junk bond yields with investment-grade bond yields. A narrower spread indicates greed and a wider spread indicates fear.

CNN-Fear-Greed-Example

Each of these components is given a score from 0 to 100, and the total score offers a snapshot of the market's emotional state. For investors, the Fear and Greed Index can serve as a valuable tool for identifying potential turning points. Extreme fear may signal a buying opportunity as prices drop, while extreme greed could suggest caution, as markets might be overextended. By tracking sentiment, the Fear and Greed Index acts as a useful complement to fundamental and technical analysis, offering an additional layer for assessing market risks and opportunities.

Developing the Index for the Indonesian Stock Market

Inspired by CNN's methodology, our objective is to develop a Fear and Greed Index specifically tailored to the Indonesian stock market. This index will rely on relevant data and indicators that effectively capture the unique dynamics of Indonesia's financial environment. CNN's index measures sentiment in the US stock market, and adapting it for Indonesia will allow us to incorporate local factors that influence market behavior, especially those related to regional economic conditions and investor psychology. In particular, adding macroeconomic indicators such as interest rates, exchange rates, and the Buffett Indicator offers insights into the market's sensitivity to broader economic shifts. These additional factors are essential for accurately gauging sentiment in a developing economy, where external economic influences can have pronounced effects on local market sentiment.

Data availability is a key consideration in defining this index. For instance, while put and call ratios are integral to CNN's index, the Indonesian stock market lacks sufficient options trading volume and reporting standards for these metrics. As a result, we'll focus on accessible, high-impact indicators that offer direct and indirect measures of investor sentiment.

Direct Indicators of Stock Market Sentiment:

  • Market Momentum: IDX Composite momentum, capturing broader market direction.
  • Stock Price Strength: Proportion of stocks hitting new highs versus lows.
  • Volatility: Measuring market stability or uncertainty.
  • Volume Breadth: Reflecting the level of participation across trades.
  • Safe Haven Demand: Balance between equity and bond demand, indicating risk appetite.

Indirect Indicators of Macroeconomic Influence:

  • Exchange Rate: Impact of currency stability on investor confidence.
  • Interest Rate: Reflects the cost of capital and economic health.
  • Buffett Indicator: Market cap-to-GDP ratio, providing a valuation benchmark for market sentiment.

Together, these indicators will offer a comprehensive, data-driven view of sentiment in the Indonesian stock market, enabling more informed analysis and potentially predictive insights.

Establishing the Mathematical Methodology

To create an effective Fear and Greed Index tailored for the Indonesian stock market, we first define the relevant indices and then outline a clear mathematical methodology. Each individual index, such as market momentum or volatility, will have its own Fear and Greed score. These scores are then combined to create a comprehensive sentiment measure for the overall market.

Step 1: Understanding Simple Moving Average Method (SMA)

The Simple Moving Average (SMA) method is a valuable tool in constructing a Fear and Greed Index as it smooths out short-term fluctuations, revealing overall trends. By averaging the last N (as you define) data points, SMA helps to reduce market noise, making it easier to detect real shifts in sentiment rather than reacting to daily volatility. This approach is adaptable to different types of data: for example, in market momentum, SMA is applied to stock closing prices, while in volatility, it may be calculated using daily changes in price or index values. For our purposes, we chose a 7-day SMA to capture market trends without overemphasizing daily fluctuations. This period balances responsiveness with trend stability and provides insight into sentiment shifts over a manageable short-term period. By consistently applying a 7-day average, we can more accurately gauge investor sentiment changes in the Indonesian market within a week's context, enabling us to maintain sensitivity to recent market behavior.

Step 2: Calculating Distance from SMA

In this step, we calculate the distance from the SMA based on the percentage change of each indicator rather than using absolute values. This approach standardizes the data, making it easier to interpret relative deviations across different indicators.

For each indicator, the daily percentage change is firstly calculated, and then the SMA is applied to these percentage changes over a selected period of 7 days. The distance between the current daily percentage change and the SMA reflects the strength of deviation, with larger positive values indicating heightened “greed” and larger negative values indicating “fear.”

Step 3: Scaling the Distance to a 0-100 Fear and Greed Index

Now that we have calculated the percentage change for each indicator, the next step is to normalize these values to fit within a 0-100 scale. This step, known as min-max scaling, ensures that each indicator aligns with the Fear and Greed Index structure, where 0 represents extreme fear and 100 represents extreme greed.

score = clip((x - min) / (max - min) * 100, 0, 100)

This formula takes the current value and scales it based on its position between the predefined minimum and maximum. Any values below the minimum threshold are clipped to 0, and any values above the maximum are clipped to 100. This ensures that the indicator always falls within the 0-100 Fear and Greed range.

Step 4: Modelling the Final Fear and Greed Index

Ultimately, we will obtain the daily scaled Fear and Greed Index for each selected indicator. These individual indices will then be combined using unsupervised machine learning models to determine the weight of each indicator, resulting in the overall Fear and Greed Index for the Indonesian market.

Note that in our methodology, the SMA calculation often uses percentage-based scaling, so the min-max scaling should apply to these percentage values. However, for some indicators, rather than using percentage changes from the SMA, we may simply calculate the absolute distance from the SMA and scale this using relative min and max values. The next article in this series will dive deeper into the specific calculations for each index as well as unsupervised machine learning modelling.

Data Sources for Calculating Sentiment Indices

Step 1: Identify Input Data Sources

To begin, we will gather the necessary input data required to calculate each of the predefined indices. Below is an overview of the key data points needed for these calculations:

Direct Indicators of Stock Market Sentiment:

  • Market Momentum: daily price changes for IDX30 stocks
  • Stock Price Strength: daily closing prices of individual stocks in the IDX30
  • Volatility: daily closing prices of IDX30 stocks
  • Volume Breadth: daily trading volume for stocks in the IDX30
  • Safe Haven Demand: the daily 10-year Indonesian government bond yield and Indonesian stock market capitalization

Indirect Indicators of Macroeconomic Influence:

  • Exchange Rate: daily exchange rate of the Indonesian Rupiah (IDR) to the US Dollar (USD)
  • Interest Rate: daily interest rate or central bank policy rate issued by Bank Indonesia
  • Buffett Indicator: market capitalization of the IDX Composite and Indonesia's GDP

To gather the necessary data for calculating our predefined indices, we categorize the data sources into two main groups:

  1. Internal Data Sources (via Sectors Financial API)
  • Daily Stock Closing Price for IDX30 stocks: Used to calculate Market Momentum, Price Strength, and Volatility indices.
  • Daily Stock Trading Volume for IDX30 stocks: Utilized in calculating the Volume Breadth index.
  • Daily Stock Market Capitalization: Essential for the Buffett Indicator, allowing us to compute market cap-to-GDP ratios.
  1. External Data Sources (via Web Scraping)
  • Interest Rate: Bank Indonesia's policy rate as published by Trading Economics, used as an indicator of macroeconomic sentiment.
  • Exchange Rate: The daily IDR-to-USD exchange rate from Trading Economics, which reflects economic stability.
  • 10-Year Indonesian Government Bonds: Yield data for 10-year government bonds, representing a benchmark for Safe Haven Demand in the market.

Data from external sources are linked above. In the next step, we will utilize Sectors Financial API to retrieve data from internal sources.

Step 2: Gathering Input Data from Sectors Financial API

Sectors Financial API offers comprehensive insights into the Indonesian stock market, allowing us to efficiently access the data needed for our analysis. First we use the companies screener to list the stocks in the IDX30.

# Retrieve the IDX30 members from the companies screener
import time
import requests
from google.colab import userdata

# Retrieve the API key securely
api_key = userdata.get('SECTORS_API_KEY')

# Define the API URL and filter by index
url = "https://api.sectors.app/v2/companies/"
querystring = {"where": "indices in ['IDX30']", "limit": 50}

# Pass the API key in the header
headers = {"Authorization": api_key}

# Make the API request
response_company_index = requests.get(url, headers=headers, params=querystring)
companies_idx30 = response_company_index.json()["results"]

print(companies_idx30)

The screener returns the matching companies under results.

[
  {
    "symbol": "ACES.JK",
    "company_name": "PT Aspirasi Hidup Indonesia Tbk"
  },
  {
    "symbol": "ADRO.JK",
    "company_name": "Adaro Energy Indonesia Tbk"
  },
  {
    "symbol": "AKRA.JK",
    "company_name": "PT AKR Corporindo Tbk."
  }
  ...
]

We will now use the “Daily Transaction Data” API and create a function that loops through company tickers to retrieve the historical market data for the IDX30 stocks.

# Retrieve date and price from "Daily Transaction Data" API
from datetime import datetime, timedelta

# Function to calculate the date 90 days ago from today
def calculate_start_date(days_ago=90):
    return (datetime.now() - timedelta(days=days_ago)).strftime('%Y-%m-%d')

# Calculate the start date 90 days ago
start_date = calculate_start_date()

# Looping API info
history_idx30 = []

for company in companies_idx30:

  # Define the URL for the API endpoint
  url = "https://api.sectors.app/v2/daily/" + company['symbol'] + "/"

  # Define the query string with the calculated start date
  querystring = {"start": start_date, "end": datetime.now().date()}

  headers = {"Authorization": userdata.get('SECTORS_API_KEY')}

  response_daily_transaction_data = requests.request("GET", url, headers=headers, params=querystring)

  # Append the result into target list
  history_idx30.append(response_daily_transaction_data.json())

  time.sleep(1)

Now if we check the result historical IDX30 data, we will have all the information we need.


[[{'symbol': 'ACES.JK',
 'date': '2024-08-07',
 'close': 735,
 'volume': 43056400,
 'market_cap': 12583493959680},
{'symbol': 'ACES.JK',
 'date': '2024-08-08',
 'close': 720,
 'volume': 52492200,
 'market_cap': 12326688260096},
{'symbol': 'ACES.JK',
 'date': '2024-08-09',
 'close': 720,
 'volume': 55467000,
 'market_cap': 12326688260096},
...
]]

history_idx30 is a list with one list of daily rows per stock. Flatten it into a DataFrame with one row per stock per day, which part 2 uses as df_history_idx30:

import pandas as pd

df_history_idx30 = pd.DataFrame([row for stock in history_idx30 for row in stock])

For other JSON shapes, see how to convert JSON to a pandas DataFrame.

Step 3: Scraping External Data and Storing It in a Database

External data sources are scraped using the BeautifulSoup library, with a GitHub Actions workflow set up to automate this process daily. This automation retrieves daily values for the interest rate, exchange rate, and 10-year Indonesian government bond rate. Since the interest rate is updated monthly, we interpolate it to a daily frequency by filling each day within the same month with the same rate.

Part 3 covers the backend data pipeline in detail.

With the methodology and data sources in place, the next part of this article computes each index.

Further reading

Frequently Asked Questions

What is the Fear and Greed Index?

The Fear and Greed Index is a sentiment gauge popularized by CNN. It combines seven market indicators into one score from 0 to 100 to show whether investors are driven more by fear or by greed. CNN publishes the live reading for the US stock market on its Markets page.

How is the Fear and Greed Index calculated?

Each of the seven indicators (stock price momentum, stock price strength, stock price breadth, put and call ratio, market volatility, safe haven demand and junk bond demand) is scored from 0 to 100 based on how far it sits from its recent average. CNN averages the seven scores with equal weight to get the headline number.

What do the Fear and Greed Index numbers mean?

Lower scores mean fear and higher scores mean greed. CNN labels 0 to 24 as extreme fear, 25 to 44 as fear, 45 to 55 as neutral, 56 to 75 as greed and 76 to 100 as extreme greed. Extreme fear can point to oversold markets, while extreme greed can be a sign that prices are overextended.

Is there a Fear and Greed Index for Indonesia?

CNN's index only covers the US market. This series builds a Fear and Greed Index for Indonesian stocks from IDX30 price, volume and market cap data plus macro indicators such as the rupiah exchange rate, Bank Indonesia's policy rate and the 10-year government bond yield.

Where can I get data to build a Fear and Greed Index for Indonesian stocks?

Daily closing prices, trading volume and market capitalization for IDX stocks are available from the Sectors Financial API, which this series uses. Exchange rate, interest rate and bond yield data come from external sources such as Trading Economics and Bank Indonesia.

Taggedmarket-sentimentfear-and-greed
Share
Sectors Snapshot: Indonesia Banks (May '25)
Sectors research

Like this piece? Take home Sectors Snapshot: Indonesia Banks (May '25).

We packed the full picture into this report by Evelyn Ong, with the numbers, charts, and context laid out end to end.

Building agents that build your business
Learn it live with our engineers

Building agents that build your business

A two-evening workshop on designing and shipping AI agents that do real work for your business: from the agentic patterns that keep them reliable, to a working multi-agent system that researches, drafts and reports on your behalf.

December 9, 2026Zoom Conferencing (Online)

Save your seatSeats from Rp490.000 (about $27)

Keep reading

Market Sentiment

Market Sentiment
Developing a Fear and Greed Index · Part 2

2. Calculations and Modelling | Fear and Greed Index

How the Fear and Greed Index is calculated, with Python code for each of the eight indicators and the weighting model that combines them into one score.

RY
Rian Yan
11 min read

Market Sentiment

Market Sentiment
Developing a Fear and Greed Index · Part 3

3. Data Engineering | Fear and Greed Index

How we source, cache and update the historical data behind an Indonesian Fear and Greed Index, from IDX prices and market cap to bonds, FX and rates.

JK
Johann C. Kandani
15 min read

Data Science in Industry

Data Science in Industry

AI for Rail Transportation

How metro operators use AI for predictive maintenance and decision support to raise MKBF (mean kilometres between failures). A guide for rail executives.

SC
Samuel Chan
13 min read

Field notes, straight to your inbox

We publish what we learn building analytics and AI systems for some of the largest enterprises in the region. Subscribe and we will send the next one your way.

The latest in AI and Enterprise Analytics

We do not resell your data. We respect your privacy and trust.