AAII Sentiment At New Spx 21 Week Highs

Nothing quantitative here, just taking a look at how the AAII setiment has been when Spx is making new 21 week rolling highs. The recent AAII setiment has turned siginificantly negative even as Spx is plowing up and wanted to see when has that happened in the past.

import quandl
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline
sns.set(style="whitegrid")

aaii = quandl.get("AAII/AAII_SENTIMENT", authtoken="YOUR_KEY")
aaii.rename(columns={"S&P 500 Weekly High":"weekly_close"}, inplace=True)
weekly_max = aaii["weekly_close"].rolling(21).max()


fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(16, 10), sharex=True)

ax1.set_title("AAII sentiment at Spx rolling 21 week highs")
ax1.plot(aaii["weekly_close"], color="#555555", label="_no_label_")
ax1.fill_between(aaii.index, 0, aaii["weekly_close"],
where=((bull_mean>=0) & (weekly_max == aaii["weekly_close"])),
color="forestgreen", alpha=0.34, label="Bullish sentiment dominant")
ax1.fill_between(aaii.index, 0, aaii["weekly_close"],
where=((bear_mean>=0) & (weekly_max == aaii["weekly_close"])),
color="crimson", alpha=0.96, label="Bearish sentiment dominant")
ax1.grid(alpha=0.21)
ax1.set_yscale("log")
ax1.legend(loc="upper left")

ax2.set_title("Normalized AAII setiment")
ax2.plot(bull_mean, linewidth=1, color="darkseagreen", label="Bullish")
ax2.plot(bear_mean, linewidth=1, color="crimson", label="Bearish")
ax2.grid(alpha=0.21)
ax2.legend(loc="upper left")
plt.margins(0.02)
fig.subplots_adjust(hspace=0.089)

Unknown-1

Advertisements

One thought on “AAII Sentiment At New Spx 21 Week Highs

  1. Quantocracy's Daily Wrap for 03/12/2017 | Quantocracy

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s