This model is made for learning puposes only and should not be used for investment or decision making.
In this project I implement the almost complete automation of the portfolio optimization and risk using the Markowitz model.
python3 and pip correctly installed
git clone https://github.com/Fnine99/Markowitz_mpt
cd Markowitz_mpt
pip install -r requirements.txt
python3 main.py
Step 1) 5 years monthly price time series data fetching on the Twelve Data API
see data.py
Step 2) Various methods on each assets including:
-Monthly prices
-Monthly returns
-Arithmetic mean return
-Geometric mean return
-Monthly returns standard deviation
see assets.py
Step 3) Portfolio construction and Various portfolio methods including:
-Portfolio return
-Porfolio covariance_matrix
-Portfolio variance
-Portfolio standard deviation
-Portfolio correlation matrix
-Portfolio inverse covariance matrix
see portfolio.py
Step 4) Portfolio optimization with Scipy algorithms including finding the assets weights which:
-Minimize the portfolio return
-Maximize the portfolio return
-Minimize the portfolio variance
-Maximize the portfolio variance
-Maximize the portfolio Sharpe ratio
see optimize.py
Step 5) Efficient frontier construction and portfolios modelling including:
-Generate X number(1M) of portfolios
-From those generated portfolios locate the assets weights which:
>Minimize the portfolio variance
>Maximize the portfolio Sharpe ratio
-Plot step 4 and 5
see frontier.py
Step 2:
Portfolio Covariance Matrix:
Portfolio Correlation Matrix:
Portfolio Inverse Covariance Matrix:
Step 4:
Note that the portfolio with asset weight bounds of [0.000, 0.900] and with a risk-free rate of 0.045. Very interesting to see that, when generating 1M of portfolios, we can very precisely predict the optimized portfolios.
Step 5: