/PortfolioOptimizer

Portfolio optimization in Python

Primary LanguagePython

Portfolio Optimizer (Python Program)

Explainer video: https://www.youtube.com/watch?v=2too70WLJUo&list=PLcJs7myZYvBBMXHgucfNKxhTqoHopfnmA&ab_channel=OptimizeEverything

Program uses Mean-Variance Portfolio Theory to create optimal portfolios and provides backtesting capabilities.

(1) First, the user inputs a list of tickers and a period of time for which data is retrieved using YahooFinance's API. The UI flow takes into account whether data exists (i.e., whether the company was publicly traded during the period of time inputted).

Screen Shot 2021-11-08 at 11 16 37 AM

(2) Next, the algorithm provides the user with the "efficient frontier". Y-axis: daily returns, x-axis: lowest standard deviation possible for each daily return.

Screen Shot 2021-11-08 at 11 18 13 AM

(3): There are two options for backtesting:

(3a) One allows the user to test how this model performs in different periods. The plot below shows the efficient frontier model developed using data from one date-range plotted in another date-range. Each point represents a portfolio, and is colored green if its return exceeds that of the model's prediction and red otherwise. The image shows the UI for testing the model's efficacy.

Screen Shot 2021-11-08 at 11 21 05 AM

Screen Shot 2021-11-08 at 11 20 21 AM

(3b) The second backtesting file conducts Monte Carlo simulation, given any average daily return and standard deviation on daily returns.

Screen Shot 2021-11-08 at 11 21 25 AM

To run: make sure you have Pandas and Numpy installed, then run main to start (i.e. enter main() into python command line).