Data and MLFeaturedL3:stock-allocation-optimizer
S&P 500 Stock Allocation Optimizer
A Streamlit app that allocates a portfolio across chosen S&P 500 stocks with linear programming and SLSQP, under sector constraints.
- Role
- Group project: app, data loading, charts and the linear programming model
- Period
- Nov 2024 to Dec 2024
Results
2 solvers
Linear programming and SLSQP compared in one view
PuLP and SciPy SLSQP with the same constraints (the optimization module in the repository).
503
S&P 500 tickers to choose from
The ticker list in the repository; prices load live from Yahoo Finance.
8 of 9
Commits by Kurniadi
Repository commit history (one commit by a teammate adds the SLSQP solver).
Problem
An investor choosing among S&P 500 stocks wants the split that maximizes return while keeping sector exposure in check, such as limits on tech and oil and gas and a minimum share per stock.
What I did
- I built the Streamlit app: stock selection, price download with yfinance for a chosen date range, cumulative return charts in Plotly and the results view.
- I modelled the allocation as a linear program in PuLP that maximizes cumulative return under tech, non-tech, oil and gas and minimum proportion constraints.
- A teammate added the same model with SciPy's SLSQP solver, so the app compares both allocations side by side.
Code and research
Repositories on GitHub
Tech stack
Python
Streamlit- PuLP
SciPy
- yfinance
Plotly
pandas