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.
|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 # Trade at the start of each trading day. schedule_function(trade, date_rule=date_rules.every_day(), time_rule=time_rules.market_open()) # This function will be called at the start of each trading day: def trade(context, data): 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