Introduction

Gold plays an essential role as a diversifier due to its low or negative correlation to other asset classes. We explore "The Fed Model," a theory that bonds can be used to judge whether the U.S. stock market is fairly valued and use this to determine entry and exit points for gold.

Method

Fed Model

Historically, the S&P 500 earning yield has a strong correlation with the 10-year Treasury note. There is the theory that if the forward earnings yield of the S&P 500 is higher than the 10-year government bond yield, stocks are undervalued and vice versa.

We import the custom fundamental data of government 10-year bond yield and S&P 500 earnings yield from Nasdaq Data Link.

# United States Government 10-Year Bond Yield   
self.bond_yield = self.add_data(NasdaqDataLinkRate, "YC/USA10Y", Resolution.DAILY, TimeZones.UTC, True).symbol
# S&P 500 Earnings Yield. Earnings Yield = trailing 12 month earnings divided by index price 
self.earnings_yield = self.add_data(NasdaqDataLink, "MULTPL/SP500_EARNINGS_YIELD_MONTH", Resolution.DAILY, TimeZones.UTC, True).symbol
# Gold Prices (Daily) - Currency USD (All values are national currency units per troy ounce)
self.gold = self.add_data(NasdaqDataLink, "WGC/GOLD_DAILY_USD", Resolution.DAILY, TimeZones.UTC, True).symbol

Gold Investment

With gold having a strong negative correlation to Equity valuations, then gold prices will rise along with earnings yield, bond yield, and inflation. Taking the above relationship a step further, this algorithm goes long gold when the Fed model shows the market undervalued otherwise liquidate the portfolio. The undervalued market is defined as the earning yield is higher than the bond yield and their ratio is at least 2. Rebalancing is done on a monthly basis.

def rebalance(self):
    if self.securities[self.earnings_yield].price == 0 or self.securities[self.bond_yield].price == 0: return
    # Buy gold if E/P is higher than the bond yield and their ratio is at least 2
    if self.securities[self.earnings_yield].price > self.securities[self.bond_yield].price * Decimal(2):
        self.set_holdings(self.gold, 0.9)
    else:
        self.liquidate()

Custom Charting

To demonstrate the relationship between government 10-year bond yield and S&P 500 earnings yield, we plot the two series in an custom chart.

def initialize(self):
    yield_plot = Chart("Yield Plot")
    yield_plot.add_series(Series("BondYield", SeriesType.LINE, 0))
    yield_plot.add_series(Series("EarningsYield", SeriesType.LINE, 0))
    self.add_chart(yield_plot)

def on_data(self, data):
    if data.contains_key(self.bond_yield) and data.contains_key(self.earnings_yield):
        self.plot("Yield Plot", "BondYield", data[self.bond_yield].price)
        self.plot("Yield Plot", "EarningsYield", data[self.earnings_yield].price)


Reference

  1. Quantpedia Premium - Gold Market Timing