Skip to content

tianw52/Stocks-Portfolio-Optimization-using-ML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CMPT 733 Final Project: A Financial Investigation into Stocks Portfolio Optimization

Group members: Tianyi Wu, Qingrui (Rachel) Li, Shiyu (Andrea) Zhao, Rebekah Wong

Welcome to our repository! Our project is an investigation into how stocks can be optimized through machine-learning based methods, namely Nested Clustered Optimization (NCO) as opposed to traditional methods like Mean Variance Optimization (MVO).

Instructions to run our project

Please ensure that all required libraries are listed in the requirements.txt file located in the NCO folder so that the scripts can run correctly.

RUN MVO results

Although we do not use the MVO methods as our website demo, you can still run them locally and view the results in the terminal. If you want to see those results, enter the following commands:

cd path/to/CMPT733-Portfolio-optimization
python3(python) -m algorithms.MVO.MVOPortfolioOptimizer

Note that we have included some example stocks in both MVO and NCO, which you can replace with others if you prefer.

Run NCO results

Please follow the web frontend instruction below to optimize your portfolio using NCO!

Simulation Testing Result:

Within the Testing folder, you will find several test scripts designed to compare MVO and NCO performance under different simulated scenarios:

  • regular_market.py: Regular market conditions
  • test1.py: High correlation
  • test2.py: High volatility
  • test3.py: Negative returns
  • test4.py: Combined worst-case scenarios
  • test5.py: Sector-specific breakdowns (e.g., technology)

Then, enter the following commands to redo the test:

cd algorithms
cd Testing
python3(python) -m algorithms.Testing.regular_market
python3(python) -m algorithms.Testing.test1
python3(python) -m algorithms.Testing.test2
python3(python) -m algorithms.Testing.test3
python3(python) -m algorithms.Testing.test4
python3(python) -m algorithms.Testing.test5

Data product: Web frontend

We have also built a website hosted locally that takes in tickers from a dropdown (S&P 500) or any other ticker that the yfinance library supports, with proper error checking to ensure that all inputs are valid.

To run the website, make sure that you have the following libraries installed:

  • datetime
  • dateutil
  • matplotlib
  • nicegui
  • numpy
  • pandas
  • pickle
  • yfinance

Then, enter the following commands:

cd website
python3 main.py

The local website can then be accessed through http://localhost:8080, or whichever link is shown in the terminal.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •