Skip to content

Instantly share code, notes, and snippets.

@benjaminmgross
Last active May 12, 2020 17:04
Show Gist options
  • Save benjaminmgross/373abac150d101373b18 to your computer and use it in GitHub Desktop.
Save benjaminmgross/373abac150d101373b18 to your computer and use it in GitHub Desktop.
Using TIPS & Treasuries to Derive Inflation Expectations & Inflation Risk Premium

##Extract Inflationary Expectations

Extract inflation expectations (and inflation risk premium) from TIPS and Treasuries

the_image

import pandas as pd
import numpy as np
import pandas_datareader as pdr
import matplotlib.pyplot as plt
# Updated for python3
tres = pdr.get_data_fred(['DGS5', 'DGS7', 'DGS10', 'DGS20', 'DGS30'], start='01/01/1900') / 100.
tips = pdr.get_data_fred(['DFII5', 'DFII7', 'DFII10', 'DFII20', 'DFII30'], start='01/01/1990') / 100.
tres.dropna(inplace=True)
tips.dropna(inplace=True)
ind = tips.index & tres.index
tips = tips.loc[ind, :]
tres = tres.loc[ind, :]
inf_exp = np.divide( (1 + tres), (1 + tips)) - 1.
fig = plt.figure(color = '#f3f3f3')
ax = plt.subplot2grid((1,1), (0,0))
inf_exp.plot(ax = ax, lw = 1.)
plt.grid(ls = '-', lw = 0.25, color = '#353535')
plt.show()
fig = plt.figure(facecolor = '#f3f3f3')
ax = plt.subplot2grid((1, 1), (0,0))
inf_exp.plot(ax = ax, lw = 1.)
plt.grid(ls = '-', lw = 0.25, color = '#353535')
plt.legend(frameon = False)
plt.title("Sum of Inflation Expectations & Inflation Risk Premium", fontsize = 24)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment