##Extract Inflationary Expectations
Extract inflation expectations (and inflation risk premium) from TIPS and Treasuries
| 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() | |