quantopian / research_public

Quantitative research and educational materials
https://www.quantopian.com/lectures
2.4k stars 1.59k forks source link

optimal_portfolio() weights seems to return 99% for 1 asset #9

Closed schalekamp closed 9 years ago

schalekamp commented 9 years ago

print weights [[ 2.77880107e-09] [ 3.20322848e-06] [ 1.54301198e-06] [ 9.99995251e-01]] <---- every time optimal_portfolio() runs the solver returns 99% weight on 1 asset

twiecki commented 9 years ago

Yeah, this is because there are so few stocks used in this example. Basically, one will always be closest to the efficient frontier. Use more stocks or shrink the means to 1.