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.
Key results
2 solvers
Linear programming and SLSQP compared in one view
503
S&P 500 tickers to choose from
8 of 9
Commits by Kurniadi
- Group project: app, data loading, charts and the linear programming model
- Nov 2024 to Dec 2024
- Featured
- L3:stock-allocation-optimizer
Results
2 solvers
Linear programming and SLSQP compared in one view
503
S&P 500 tickers to choose from
8 of 9
Commits by Kurniadi
Problem
An investor choosing among S&P 500 stocks needs a way to compare allocations using historical returns while keeping sector exposure in check, such as limits on tech and oil and gas and a minimum share per stock.
Contribution
- 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 over the selected historical period, 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
StreamlitSciPy
Plotly
pandas
- PuLP
- yfinance