Skip to content

Basics of modern portfolio theory demonstrated via Python for efficiency

Notifications You must be signed in to change notification settings

nikoelvambuena95/FinancialAnalysis_PortfolioTheoryBasics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Portfolio Theory Basics: The Efficient Frontier, the CAPM, and the Sharpe Ratio

In this project I outline the beginning foundation of modern portfolio theory and its underlying basics. I calculate and graph key portfolio performance indicators - the Efficient Frontier, the CAPM, and the Sharpe Ratio - using Python. Hopefully this highlights how powerful, efficient, and informative using programming is for financial analysis.


Markowitz's Efficient Frontier

Harry Markowitz was an American economist that created the Efficient Frontier model in 1952. This model finds optimal asset portfolios that give the highest returns with minimal risk. To achieve this optimal portfolio, different weights for assets in the portfolio are used to produce desired returns. This concept is central to the risk-return trade-off at the cornerstone of modern portfolio management philosophies.

To find the Efficient Frontier, also known as Markowitz's Bullet, we plot the Expected Return on the y-axis and the Portfolio Risk (as Standard Deviation) on the x-axis.

To calculate the Expected Return we use the formula below:

$R = (w_{1}*r_{1}) + (w_{2}*r_{2}) + (w_{3}*r_{3}) + ...$

  • Expected Return ($R$)
  • Portfolio Weight of Asset ($w_{x}$)
  • Rate of Return of Asset ($r_{x}$)

By using this formula with various assets' weights we can calculate different Expected Returns for a portfolio.

To calculate the Portfolio Risk we use the formula below:

$\sigma P = \sqrt{(w_{1}^{2}*\sigma_{1}^{2})+(w_{2}^{2}*\sigma_{2}^{2})+((2*Corr)*\sigma_{1}*\sigma_{2}})$

  • Portfolio Risk ($\sigma P$)
  • Portfolio Weight of Asset ($w_{x}$)
  • Standard Deviation of Asset ($\sigma_{x}$)
  • Correlation Coefficient ($Corr$)

Lucky for us, all these calculations can be handled using Python.

The Capital Asset Pricing Model

The Capital Assest Pricing Model (CAPM) formula:

$r_{i} = r_{f} + \beta_{im}(r_{m}-r_{f})$

The CAPM is a measure of the the risk and return of a security investment. There are three essential components to the CAPM:

  • Risk-Free Return ($r_{f}$)
  • Market Risk Premium ($r_{m}-r_{f}$)
  • Beta of the investment ($\beta_{im}$)

The Risk-Free Return ($r_{f}$) is the value of an investment that carries zero risk. In reality there is no investment that carries a true risk rate equal to zero. A close investment that actually nears zero is the US 10-year government bond. This is because the US government is extremely unlikely not to pay back its bond holders - hence the near risk-free status and why it is often used in CAPM calculations for US markets.

The Market Risk Premium $(r_{m}-r_{f})$ is the return that is expected from the portfolio beyond the risk-free assets. This premium rate is a strong determinant in whether or not pursuing the given portfolio will produce significant returns. In other words, this return is crucial in measuring portfolio performance in the CAPM.

The Beta ($\beta_{im}$) is a measure of the stock's volatility. More specifically, this component of the CAPM is a measure of the idiosyncratic or unsystematic risk. This is the risk that can be mitigated through investment diversification throughout a portfolio.

Beta value

We get the Beta ($\beta$) value using the formula below:

$\large \beta = {Cov(r_{x},r_{m}) \over \sigma^{2}_{m}}$

The Beta value indicates the relationship the investment has in relation to the market. In other words, this metric will show if an investment will or will not behave similarly to the rest of the market.

If $\beta = 0$, then the stock behaves indepdently of the market.

If $\beta < 1$, then the stock is defensive because they will lose less in poor markets - i.e. they are safe in poor markets.

If $\beta = 1$, then the stock performs the same as the market.

If $\beta > 1$, then the stock is aggresive because they are riskier investments BUT they perform better than the market.

The Sharpe Ratio

The Sharpe ratio formula:

$\large {r_{i}-r_{f} \over\sigma_{i}}$

  • Risk-Free Return ($r_{f}$)
  • Return of the investment ($r_{i}$)
  • Standard Deviation of the investment ($\sigma_{i}$)

The Sharpe ratio is a metric used to calculate an investment or portfolio's risk-adjusted return. It also highlights any additional return that is gained after taking on the risk.

Considered simply, a higher Sharpe ratio or index indicates a better return relative to the risk of the investment or the relationship of the investments in the portfolio.