Idea Streams #7 – Why Is Everyone Buying Gold?
The price of gold reached a new all-time high of $2075 in August 2020. A few days before the peak, the New York Times attributed the mania to the public bracing for inflation in response to “the easy money pouring out of central banks and government stimulus programs”. Paul Krugman disagreed on Twitter, stating that the price of gold is not rising because investors are expecting inflation but rather because bond yields are so low. In response, Peter Schiff called Krugman “clueless”, claiming that inflation explains both the fall in bond yields and the rise in gold prices.
We wanted to test the claims from these sources and uncover the underlying reason for the gold rally. So in Idea Streams episode #7, we analyzed the relationship between gold prices, expected inflation, and bond yields.
To observe the relationship between gold prices, expected inflation, and bond yields, we gathered two data sets from the Federal Reserve Economic Data (FRED) website. For the expected inflation rate, we used the 10-year breakeven Inflation rate. For the bond yields, we used the 10-year treasury inflation-indexed bond yield data. The 10-year breakeven inflation rate is a calculation based on whether yields are equal on inflation-protected and non-inflation-protected treasuries. The latest value in the series represents what the average investor expects inflation to be 10 years into the future.
The 10-year treasury inflation-indexed bond yield data is corrected for inflation, so we can see at the moment there are negative bond yields on these 10-year treasuries.
To get these datasets from FRED into our research environment, we uploaded the data to Dropbox and created two custom data classes to read the Dropbox files. Once the data was ready to be read, we added the gold spot price and the two custom data sets to our research environment.
self.gold = self.AddCfd("XAUUSD", Resolution.Daily, Market.Oanda).Symbol self.infl = self.AddData(ExpectedInflation, "infl", Resolution.Daily).Symbol self.yld = self.AddData(TenYrYield, "yld", Resolution.Daily).Symbol
We then gathered 15 years of historical data for the 3 data sets.
history = self.History([self.gold, self.infl, self.yld], timedelta(365*15))
With all of the data in one place, we organized it into one large DataFrame. Since the price of gold has a high positive skew, we applied a log transformation to the values in order to make the linear regression results more reliable. After manipulating the data into place, here’s what the first 5 rows of the final DataFrame looked like:
To observe the relationship between gold and the other variables, we produced two scatter plots.
Looking at the plots above, it doesn’t seem like there is much of a relationship between inflation and gold. However, it looks like there is a strong negative correlation between bond yields and the price of gold. To see how these relationships have fared over time, we colored the scatter plots so darker dots represented more recent dates.
From these plots, we can see the relationship between the gold price and bond yields has held up well in recent times. Additionally, inflation seems to be having a somewhat positive correlation recently. If we narrow our scope and look at just the data since March 1, 2020, it appears there is a strong positive correlation between inflation and gold prices, and a strong negative correlation between bond yields and gold prices.
To assign some numbers to these relationships, we calculated the correlation coefficients and R-square values. Over the last 15 years, the correlation between gold and inflation was -0.14 (0.02 R-Square), and the correlation between gold and bond yields was -0.91 (0.84 R-Square). This tells us that over the last 15 years, 84% of gold price variability can be accounted for by bond yields and only 2% can be attributed to the variability in inflation.
When we computed the R-Square values over just the data starting March 1, 2020, we found that gold and inflation had an R-Square value as high as 0.71. However, this is only because gold, inflation, and bond yields were all highly correlated over the last few months. In conclusion, we can determine there has been a strong long-term relationship between bond yields and gold prices, but there hasn’t been a stable long-term relationship between gold prices and inflation.
With these findings in mind, we designed our trading strategy. We set the start of the backtest to January 1, 2019. We created a Scheduled Event to train a linear regression model at the beginning of each month.
self.Schedule.On(self.DateRules.MonthStart("XAUUSD"), \ self.TimeRules.At(0, 0), \ self.fit_model)
The model was trained to predict the logarithmic gold price using the latest bond yield as input. To ensure the model was trained only on recent data, we fit the model using only data from the trailing 365 days. Once trained, if the model predicted a price greater than the current gold price, we allocated 100% of our portfolio to XAUUSD. Otherwise, we liquidated our portfolio to only hold cash.
predicted_price = np.exp(self.model.predict([[bond_yield]])) if predicted_price > gold_price: self.SetHoldings(self.gold, 1) else: self.SetHoldings(self.gold, 0)
The results of our backtest showed this strategy placed 40 trades. Through those trades, the strategy was able to produce a 2.4 Sharpe ratio and a 98% PSR. These results are impressive, but our backtest period coincided with a massive increase in the price of gold. Therefore, before deploying the strategy live, we recommend running a longer backtest to see how the strategy performs during different market regimes.