Implementing Markowitz portfolio optimization with pyportfolioopt, backtest a strategy to rebalance the tangency portfolio (max sharpe) every half a month.
Instructions:
-
Run 'pip install -r requirements.txt'
-
Run 'Python backtest.py'
Price data of the tickers will be downloaded as csv files.
Backtesting framework used is backtrader.
Under Markowitz's portfolio theory, the efficient frontier is the curve which consists of all the portfolios that generate highest return for the given level of risk in the set of all portfolios. Mathematically, can be obtained by minimizing the variance of the portfolio, subject to constraints.
The most optimal portfolio in terms of risk and reward is not the minimum variance portfolio, but instead the one with maximum sharpe ration. Sharpe ratio is the expected return, accounting for the amount of risk taken
To locate this portfolio, we require the Capital Market Line as well, as the point where CML is tangent to efficient frontier is the tangency portfolio. The sharpe ratio is actually the the slope of the CML.
Using the Capital Market Line, an optimization problem can be stated and solved by pyportfolioopt.
ALL images found on google