Markowitz portfolios

Pengantar Manajemen Risiko Portofolio dengan Python

Dakota Wixom

Quantitative Analyst | QuantCourse.com

100,000 randomly generated portfolios

Pengantar Manajemen Risiko Portofolio dengan Python

Sharpe ratio

The Sharpe ratio is a measure of risk-adjusted return.

To calculate the 1966 version of the Sharpe ratio:

$$ S = \frac{ R_a - r_f }{\sigma_a} $$

  • S: Sharpe Ratio
  • $ R_a $: Asset return
  • $ r_f $: Risk-free rate of return
  • $ \sigma_a $: Asset volatility
Pengantar Manajemen Risiko Portofolio dengan Python

The efficient frontier

Pengantar Manajemen Risiko Portofolio dengan Python

The Markowitz portfolios

Any point on the efficient frontier is an optimum portfolio.

These two common points are called Markowitz Portfolios:

  • MSR: Max Sharpe Ratio portfolio
  • GMV: Global Minimum Volatility portfolio

Pengantar Manajemen Risiko Portofolio dengan Python

Choosing a portfolio

How do you choose the best portfolio?

  • Try to pick a portfolio on the bounding edge of the efficient frontier
  • Higher return is available if you can stomach higher risk
Pengantar Manajemen Risiko Portofolio dengan Python

Selecting the MSR in Python

Assuming a DataFrame df of random portfolios with Volatility and Returns columns:

numstocks = 5
risk_free = 0
df["Sharpe"] = (df["Returns"] - risk_free) / df["Volatility"]
MSR = df.sort_values(by=['Sharpe'], ascending=False)
MSR_weights = MSR.iloc[0, 0:numstocks]
np.array(MSR_weights)
array([0.15, 0.35, 0.10, 0.15, 0.25])
Pengantar Manajemen Risiko Portofolio dengan Python

Past performance is not a guarantee of future returns

Even though a Max Sharpe Ratio portfolio might sound nice, in practice, returns are extremely difficult to predict.

Pengantar Manajemen Risiko Portofolio dengan Python

Selecting the GMV in Python

Assuming a DataFrame df of random portfolios with Volatility and Returns columns:

numstocks = 5
GMV = df.sort_values(by=['Volatility'], ascending=True)
GMV_weights = GMV.iloc[0, 0:numstocks]
np.array(GMV_weights)
array([0.25, 0.15, 0.35, 0.15, 0.10])
Pengantar Manajemen Risiko Portofolio dengan Python

Let's practice!

Pengantar Manajemen Risiko Portofolio dengan Python

Preparing Video For Download...