Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portfolio asset distribution generator

The project computes optimal portfolio weight distributions based on the maximum Sharpe ratio, using historical stock price data.

It allows users to to input a set of stock tickers and compares two different optimization approaches for portfolio construction.

The Sharpe ratio is used to measure return per unit of risk relative to a risk-free investment.
You can learn more about Sharpe ratio here.

Optimization approaches

1. Analytic maximum Sharpe portfolio

  • Long and short selling is allowed.
  • Risk-free rate is not accounted for (= 0).

2. Numeric maximum Sharpe portfolio

  • Long-only portfolio (weights constrained to [0, 1]).
  • Risk-free rate is inputted by the user (currently not possible).
  • Optimized using Sequencial Least Squares Programming (SLSQP).

How it works

  • The user inputs stock tickers to include in the optimised portfolio.
  • Monthly returns are calculated using downloaded historical price data (2020-01-01 to 2025-12-31).
  • Both optimization approaches are computed and generate portfolio weights.

If you want to try out the source code yourself, create a virtual environment and download the required libraries listed in requirements.txt:

python -m venv .venv
pip install -r requirements.txt

And run the code:

python3 PortfolioGen.py

Important Notes

  • The Sharpe ratio is calculated only using historical returns data and does not predict future market performance.

  • This tool does not attempt to predict price movements, but rather evaluate how well past returns compensated for risk.

Disclaimer

This project is for educational and analytical purposes only. It is not financial advice and should not be used as the sole basis for investment decisions.

Future improvements

  • Add Treynor ratio for comparison between Sharpe.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages