Fear and greed, part 2: does smoothing the index help?
In part 1, I created my own fear and greed index to get daily values as far back as possible. To reach 1927, I used three measures of US stock returns, while CNN uses seven, some from other asset classes. I showed that timing the market with this fear and greed index returned 6.5% a year, versus 10.0% for staying invested.
This timing strategy has two parts: the rule (buying stocks when the index was below 25 and selling them for Treasury bills when it was above 75) and the index the rule uses. Smoothing the index could improve timing for buying and selling stocks. It cut the switches from 220 to 74 or fewer, but only one smoothed version beat staying invested, with a single switch in 1937.
The index moved back and forth across 25
As in part 1, I use two daily files from Kenneth French’s data library and build the index with the same code.
import hashlib
import io
import urllib.request
import zipfile
from itertools import takewhile
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from matplotlib.ticker import FuncFormatter
LIBRARY = "https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/"
def download(name):
with urllib.request.urlopen(LIBRARY + name) as response:
content = response.read()
archive = zipfile.ZipFile(io.BytesIO(content))
print(name, "| sha256", hashlib.sha256(content).hexdigest())
member = next(file for file in archive.namelist() if file.lower().endswith(".csv"))
return archive.read(member).decode("latin-1")
def daily_table(text, title=""):
lines = text.splitlines()
first = next(number for number, line in enumerate(lines) if title in line)
start = next(number for number in range(first, len(lines)) if lines[number].startswith(","))
rows = list(takewhile(str.strip, lines[start:]))
table = pd.read_csv(io.StringIO("\n".join(rows)), index_col=0)
table.index = pd.to_datetime(table.index.astype(str).str.strip(), format="%Y%m%d")
table.columns = table.columns.str.strip()
return table.replace([-99.99, -999], float("nan")) / 100
factors = daily_table(download("F-F_Research_Data_Factors_daily_CSV.zip"))
industries = daily_table(download("12_Industry_Portfolios_Daily_CSV.zip"),
"Average Value Weighted Returns -- Daily")
market = factors["Mkt-RF"] + factors["RF"]
bills = factors["RF"]
dates = market.index
if not (dates.is_unique and dates.is_monotonic_increasing and industries.index.equals(dates)
and industries.shape[1] == 12):
raise ValueError("the two files do not match: other dates or not 12 industries")
if market.isna().any() or industries.isna().any().any():
raise ValueError("a return is missing")
print("downloaded", pd.Timestamp.today().date(), "|", market.index[0].date(), "to",
market.index[-1].date(), "|", len(market), "trading days")F-F_Research_Data_Factors_daily_CSV.zip | sha256 96c23b88e651cbfff3740a53f8225e59ee39893371e96385a1d8125ec2cd9c89
12_Industry_Portfolios_Daily_CSV.zip | sha256 d11f87b42f301ea931d1ddc823d3e2125aba4c8310eeeec43f96554e98b1ebb4
downloaded 2026-11-25 | 1926-07-01 to 2026-09-30 | 26338 trading days
wealth = (1 + market).cumprod()
industry_wealth = (1 + industries).cumprod()
industry_average = industry_wealth.rolling(125).mean()
above = (industry_wealth > industry_average).astype(float).where(industry_average.notna())
inputs = pd.DataFrame({"momentum": wealth / wealth.rolling(125).mean() - 1,
"participation": above.mean(axis=1, skipna=False),
"calm": -market.rolling(20).std()})
ranks = inputs.rolling(253, min_periods=253).rank(method="average")
fear_greed = (100 * (ranks - 1).sum(axis=1, min_count=3) / (252 * 3)).dropna()
if not fear_greed.index.equals(dates[dates >= fear_greed.index[0]]):
raise ValueError("a score is missing after the first score")
print("first score", fear_greed.index[0].date(), "| last score", fear_greed.index[-1].date(),
round(fear_greed.iloc[-1], 1))
print("correlation with the day before: index", round(fear_greed.autocorr(1), 2),
"| daily market return", round(market[fear_greed.index].autocorr(1), 2))
below = fear_greed < 25
periods = (below != below.shift()).cumsum()[below].value_counts()
print("periods below 25:", len(periods), f"| median length: {periods.median():g} trading days")first score 1927-10-01 | last score 2026-09-30 29.6
correlation with the day before: index 0.98 | daily market return 0.05
periods below 25: 416 | median length: 5 trading days
The index is not as random as the daily market return. Its correlation with the previous day’s value is 0.98, compared with 0.05 for the daily market return. But it still moved back and forth across 25. The index fell below 25 and came back 416 times, and at least half the time it stayed below 25 for 5 trading days or fewer.
Two averages smooth the index
To reduce this back-and-forth, I compute a rolling average of the index each day, using its values over the last 63 and 252 trading days, about three months and one year. I also use an exponential moving average over the same horizons, which assigns more weight to recent days.
days = fear_greed.index
years = (days[-1] - days[0]).days / 365.25
per_year = (len(days) - 1) / years
versions = {
"index without smoothing": fear_greed,
"63-day rolling average": fear_greed.rolling(63).mean(),
"252-day rolling average": fear_greed.rolling(252).mean(),
"63-day exponential moving average": fear_greed.ewm(span=63, adjust=False).mean(),
"252-day exponential moving average": fear_greed.ewm(span=252, adjust=False).mean(),
}Smoothing cuts the switches from 220 to 74 or fewer
I run part 1’s rule on the index without smoothing and on the four smoothed indexes, five versions in all. The rule starts in Treasury bills, and from 25 to 75, it keeps its holding. As in part 1, I create the signal from each day’s close, so the new holding earns the next trading day’s return.
def run_rule(index, buy_below=25, sell_above=75):
index = index.reindex(days)
decision = pd.Series(float("nan"), index=days)
decision[index < buy_below] = 1.0
decision[index > sell_above] = 0.0
target = decision.ffill().fillna(0.0)
in_stocks = target.shift(1, fill_value=0.0)
rule = market[days].where(in_stocks == 1, bills[days])
rule.iloc[0] = 0.0
return rule, in_stocks
def describe(rule, in_stocks, name):
growth = (1 + rule).cumprod()
excess = rule.iloc[1:] - bills[days].iloc[1:]
drawdown = growth / growth.cummax() - 1
row = pd.Series({"return a year": growth.iloc[-1] ** (1 / years) - 1,
"volatility a year": rule.iloc[1:].std() * per_year ** 0.5,
"Sharpe ratio": excess.mean() / excess.std() * per_year ** 0.5,
"worst drawdown": drawdown.min(),
"$1 grew to": growth.iloc[-1],
"days in stocks": in_stocks.iloc[1:].mean(),
"switches": int(in_stocks.diff().abs().sum())}, name=name)
return row, growth
market_only = market[days].copy()
market_only.iloc[0] = 0.0
row, curve = describe(market_only, pd.Series(1.0, index=days), "Staying invested")
row["below 25 %"] = float("nan")
row["above 75 %"] = float("nan")
rows, curves = [row], {"Staying invested": curve}
for name, index in versions.items():
rule, in_stocks = run_rule(index)
row, curve = describe(rule, in_stocks, name)
row["below 25 %"] = 100 * (index.dropna() < 25).mean()
row["above 75 %"] = 100 * (index.dropna() > 75).mean()
rows.append(row)
curves[name] = curve
table = pd.DataFrame(rows)
formats = {"return a year": "{:.1%}".format, "volatility a year": "{:.1%}".format,
"Sharpe ratio": "{:.2f}".format, "worst drawdown": "{:.1%}".format,
"$1 grew to": "${:,.0f}".format, "days in stocks": "{:.1%}".format,
"switches": "{:,.0f}".format, "below 25 %": "{:.1f}".format,
"above 75 %": "{:.1f}".format}
print(table.to_string(formatters=formats))
after_costs = (table["$1 grew to"] * (1 - 0.001) ** table["switches"]).drop("Staying invested")
print("$1 after 0.1% a switch:",
", ".join(f"{name} ${value:,.0f}" for name, value in after_costs.items())) return a year volatility a year Sharpe ratio worst drawdown $1 grew to days in stocks switches below 25 % above 75 %
Staying invested 10.0% 17.5% 0.45 -84.1% $12,919 100.0% 0 NaN NaN
index without smoothing 6.5% 14.0% 0.30 -64.5% $512 49.0% 220 22.1 19.0
63-day rolling average 6.3% 14.0% 0.28 -75.2% $417 49.5% 74 13.8 11.6
252-day rolling average 4.0% 7.5% 0.14 -50.7% $47 12.2% 5 1.2 0.9
63-day exponential moving average 6.4% 14.9% 0.28 -73.6% $462 59.1% 68 12.8 9.7
252-day exponential moving average 10.3% 14.7% 0.53 -54.6% $16,461 88.4% 1 1.0 0.0
$1 after 0.1% a switch: index without smoothing $411, 63-day rolling average $387, 252-day rolling average $47, 63-day exponential moving average $432, 252-day exponential moving average $16,444
Of the four smoothed versions, three had a lower return a year than the version without smoothing, and the same three had a lower Sharpe ratio. The rule on the 252-day exponential moving average improved the return to 10.3% a year, versus 10.0% for staying invested.
BACKGROUND, INK, GRID, FRAME, LABEL = "#FCEFE3", "#1F1F1F", "#EADCCC", "#D5C6B4", "#4a4a4a"
TEAL, ORANGE, GREY = "#17868A", "#D2822B", "#7a7168"
def site_style(figure, axes):
figure.patch.set_facecolor(BACKGROUND)
for axis in axes:
axis.set_facecolor(BACKGROUND)
axis.grid(True, axis="y", color=GRID, lw=1.0)
axis.set_axisbelow(True)
axis.spines[["top", "right"]].set_visible(False)
axis.spines[["left", "bottom"]].set_color(FRAME)
axis.tick_params(length=0, colors=GREY, labelsize=12.5, pad=6)
axis.xaxis.label.set(color=LABEL, fontsize=14)
axis.yaxis.label.set(color=LABEL, fontsize=14)
figure, (top, middle, bottom) = plt.subplots(3, 1, figsize=(12, 12), sharex=True,
height_ratios=[1, 1, 2])
palette = [TEAL, ORANGE, "#7B5EA7", "#B23A48"]
top.plot(fear_greed.index, fear_greed, color=INK, lw=0.3)
top.set_ylabel("Index without smoothing")
top.set_ylim(0, 100)
for (name, series), color in zip(list(versions.items())[1:], palette):
middle.plot(series.index, series, lw=1.1, color=color, label=name)
middle.set_ylabel("Index, smoothed")
middle.set_ylim(0, 100)
middle.legend(loc="lower left", bbox_to_anchor=(0, 1), ncol=2, frameon=False, fontsize=10.5)
for axis in (top, middle):
axis.axhline(25, color=GREY, lw=1.1, ls="--")
axis.axhline(75, color=GREY, lw=1.1, ls="--")
for (name, curve), color in zip(curves.items(), [GREY, INK] + palette):
bottom.plot(curve.index, curve, lw=1.7, color=color, label=name[0].upper() + name[1:])
bottom.set_yscale("log")
bottom.yaxis.set_major_formatter(FuncFormatter(lambda value, _: f"${value:,.0f}"))
bottom.tick_params(axis="y", which="minor", left=False)
bottom.set_ylabel("Value of $1 (log scale)")
bottom.legend(loc="upper left", fontsize=10.5, facecolor=BACKGROUND, edgecolor="none",
framealpha=1)
site_style(figure, [top, middle, bottom])
figure.tight_layout()
figure.savefig("fear_greed_smoothing.png", dpi=200, facecolor=BACKGROUND)
plt.show()
The rule switched once on the 252-day exponential moving average
The rule on the 252-day exponential moving average did better than staying invested, but only because it switched to stocks once, on 19 November 1937, after the 1929-1932 crash. It avoided the loss on stocks over the long stretch before that switch.
version = "252-day exponential moving average"
smooth = versions[version]
first = smooth[smooth < 25].index[0]
print(f"{version}: first close below 25 on", first.date(), "| highest close after it:",
round(smooth[first:].max(), 1), "on", smooth[first:].idxmax().date())
staying = curves["Staying invested"][first]
print(f"$1 from {days[0].date()} on {first.date()}: staying invested ${staying:.2f}",
f"| Treasury bills ${curves[version][first]:.2f}")
print("years with a close below 25:", smooth[smooth < 25].index.year.unique().tolist())252-day exponential moving average: first close below 25 on 1937-11-19 | highest close after it: 73.2 on 2004-02-03
$1 from 1927-10-01 on 1937-11-19: staying invested $0.88 | Treasury bills $1.13
years with a close below 25: [1937, 1938, 1966, 1973, 2008, 2009, 2022]
This result has two issues. First, although smoothing the fear and greed index did help, its whole gain over staying invested came before its one switch in these 99 years, and I do not believe anyone would be waiting for that signal. Second, reducing switching is not enough to improve returns, as the other three smoothed versions switched less without improving returns relative to the version without smoothing.
Limitations
The levels stay at 25 and 75. Smoothing reduces the time the index spends below 25 or above 75. The smoothed indexes move so slowly that one could adjust the levels to increase switching, but that is outside this post.
The start date matters. If I had started this analysis in 1950, the rule on the 252-day exponential moving average would have held Treasury bills until 1966.
All returns in the table are before trading costs and taxes. Costs and taxes add up over time, especially with each switch, so the results provide an upper bound on how well the strategies could have done.
Conclusion
Smoothing the fear and greed index does not necessarily improve market timing. It did so for one of the four smoothed versions, but because that version switched only once, the reader should be skeptical of its value.
References
French, K. R. (2026a). Fama/French 3 factors [Daily data set, September 2026 release]. Kenneth R. French Data Library. https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/Data_Library/f-f_factors.html
French, K. R. (2026b). 12 industry portfolios [Daily data set, September 2026 release]. Kenneth R. French Data Library. https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/Data_Library/det_12_ind_port.html
Read next
- Fear and greed index backtest since 1927: buying in fear trailed staying invested From October 1927 to September 2026, buying in fear and selling in greed turned $1 into $512, against $12,919 for staying invested.
- CAPE ratio backtest: time in the market vs timing the market since 1891 From 1891 to 2026, time in the market turned $1 into $8,587 after inflation, against $350 for timing the market with CAPE.
- Does a large one-day move in the S&P 500 predict next week’s return? The S&P 500’s median next-week return was far from zero only after one-day moves of 5% or more, and opposite in sign to those moves.
Disclaimer: a teaching example, not investment advice.
Data: Kenneth R. French, Data Library, daily Fama/French factors and 12 industry portfolios (value-weighted), September 2026 release, July 1926 to September 2026, downloaded on 25 November 2026. I publish only results computed from the data.