Capital Market Line
We saw the capital market line in the last lesson. It is the combination of a risk-free asset and the most effecient portfolio. It allows us to get either a specific level of risk or a specific return at the most effecient level.
This equation is linear, the intercept is the risk-free rate where we have 0% in the portfolio, and then the line is the premium of the portfolio over the risk-free rate for every 100% of exposure to the portfolio. In the model we can borrow at the risk-free rate, but in reality the CML will be a piecewise graph because when a consumer borrows they will always pay more than the risk-free rate (since an investor is by no means risk-free, they could default especially if they do not get the expected return).
import matplotlib.pyplot as plt
def CML(rf,rm,marketSD,label):
portfolioSD = [(marketSD*x)/25 for x in range(51)]
portfolioReturns = [rf+((rm-rf)/marketSD)*x for x in portfolioSD]
plt.plot(portfolioSD,portfolioReturns,label=label)
plt.xlabel("Porfolio Standard Deviation")
plt.ylabel("Portfolio Return")
plt.title("Capital Market Line")
plt.plot(marketSD,rm,"ro")
The first line sets up levels of standard deviation from 0 to 200% exposure. The second line gives us the return at each sd, and the label gives us a label for our line when we plot the legend (outside of the function). We also plot the point of 100% exposure.
CML(.02,.08,.35,"Line 1")
plt.legend()
plt.show()
What if both the portfolio and the risk-free get pushed up by 2%?
CML(.02,.08,.35,"Line 1")
CML(.04,.10,.35,"Line 2")
plt.legend()
plt.show()
We get a full shift upwards. What if only the risk-free went up?
CML(.02,.08,.35,"Line 1")
CML(.04,.08,.35,"Line 2")
plt.legend()
plt.show()
The intercept shifts up, but the slope decreases because of the opportunity cost. Below the 100% level of exposure we get more return since we get the benefit of more risk-free return but after that mark we get a lower return since we now have to pay more to borrow.