Trading with the CNN Fear & Greed Index (Updated)

CNN has a Fear and Greed Index for the market. This Index supposedly shows how fearful or greedy investors are at the time. The F&G Index ranges from 0-100, 0 being the most fearful and 100 being the most greedy. If investors are greedy stock prices should rise; if they are fearful stock prices should fall. So, if someone traded base off only this Index for five years, how would they do? This algorithm goes long when the Index is above 50, and goes short when the Index is below 50. That threshold value can be changed in the algorithm.

This has more data than my original version, and is slightly modified. This version of the strategy runs in minute-mode and trades at the start of every day using the previous day's Index. You can see that the strategy somewhat follows the market, and does not do very well, indicating that the F&G Index isn't a great indicator.

Play around with the strategy by cloning it below and let me know what you think. There may be better ways to trade with the F&G Index than this simple one.

84
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
 Returns 1 Month 3 Month 6 Month 12 Month
 Alpha 1 Month 3 Month 6 Month 12 Month
 Beta 1 Month 3 Month 6 Month 12 Month
 Sharpe 1 Month 3 Month 6 Month 12 Month
 Sortino 1 Month 3 Month 6 Month 12 Month
 Volatility 1 Month 3 Month 6 Month 12 Month
 Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Fear and Greed Index trading strategy
# Based off of http://money.cnn.com/data/fear-and-greed/

# Strategy:
# Every morning, trade using the previous day's signal.
# Go long when the F&G Index is high (market is supposedly greedy).
# Go short when the F&G Index is low (market is supposedly fearful).

# Initialize the algorithm:
def initialize(context):
context.security = sid(8554) # Trade SPY

# Load daily F&G Index data:
context.query = 'fgindex'
fetch_csv('http://pastebin.com/raw.php?i=WZKu8b38',
date_format='%Y-%m-%d',
symbol=context.query
)

# If the F&G Index is above this value we go long. Otherwise, we go short:
context.threshold = 50

# This function will be called at the start of each trading day:
fear_and_greed_index = data[context.query][context.query]

if fear_and_greed_index > context.threshold:
order_target_percent(context.security, 1)
else:
order_target_percent(context.security, -1)

# Record the F&G Index and our threshold:
record(F_and_G_index = fear_and_greed_index, threshold = context.threshold)

def handle_data(context, data):
pass
There was a runtime error.
Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

1 response

Also of interest may be Andrew's post on recreating the Index.