From the thread on Bogleheads: A mean variance framework for portfolio optimization
Here I've added a requirements.txt
file to make it easier to get running.
Create a virtual env if you haven't already:
python3 -m venv venv
Activate the virtual env:
source venv/bin/activate
Install dependencies:
pip install -r requirements.txt
Now you can run the script:
python mvo_original.py
See the linked thread above for more details.
You can add more assets and adjust the expected returns, volatility, correlations, etc.
I also created a script for calculating your CRRA (constant relative risk aversion, aka "gamma").
For help, run:
python crra.py -h
Special thanks to Bogleheads user Uncorrelated for producing the original code and dedicating it to the public domain.