-
Return and Variance 7
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
Lecture1.5
-
Lecture1.6
-
Lecture1.7
-
-
Solving Equations 5
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
-
Capital Allocation Line 6
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
Lecture3.5
-
Lecture3.6
-
-
Diversification 3
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
-
Investment Sets 3
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
-
Portfolios 7
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
Lecture6.4
-
Lecture6.5
-
Lecture6.6
-
Lecture6.7
-
-
Capital and Security Market Lines 3
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
-
Arbitrage 3
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
-
Dividend Discount Model 2
-
Lecture9.1
-
Lecture9.2
-
-
Fixed Income 4
-
Lecture10.1
-
Lecture10.2
-
Lecture10.3
-
Lecture10.4
-
-
Duration and Immunization 4
-
Lecture11.1
-
Lecture11.2
-
Lecture11.3
-
Lecture11.4
-
Yield Curve
The yield curve is a represenation the yield for different maturities.
You can get the yield for each bond like we have done in the past, but I want to show you how to get the yields from Fred to construct the yield curve. If we were given the prices instead of yields for each maturity, we would have to calculate the yields from price first.
import datetime
import pandas_datareader as pdr
start = datetime.datetime(2016, 1, 1)
end = datetime.datetime(2017, 1, 1)
bondYields = pdr.fred.FredReader(["TB3MS","TB6MS","TB1YR","GS5","GS10","GS30"], start, end).read()
print(bondYields)
From FRED, we get the yields for 3 month, 6 month, 1 year, 5 year, 10 year and 30 year treasury securities.
If you forgot, we can get the last row of our dataframe as such….
print(bondYields.iloc[-1,:])
Plotting….
import matplotlib.pyplot as plt
plt.plot([.25,.5,1,5,10,30],bondYields.iloc[-1,:])
plt.title("Yield Curve")
plt.xlabel("Maturity")
plt.ylabel("Yield")
plt.show()
Challenge
Plot the 2010 yield curve and the 2017 yield curve to compare.
Prev
Yield Measures
Next
Solution