Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to set minimum number of stocks in portfolio and maximum position concentration?

Hey guys,

I have a question regarding the portfolio optimization API.

I would like to hold 500 stocks in my portfolio and the maximum position weights should be 2% for example.

Does someone know how to achieve this?

If I maximize the alpha factor of my pipeline output of 500 stocks and set the maximum position concentration to, for example 2%, I find only 50 stocks in my portfolio. How can I change it to constantly 500 stocks in the portfolio with a maximum concentration of 2%?

Thanks a lot for your help

kind regards

Marcel

1 response

to hold 500 stocks you need to set the bounds to 1/500 = 0.002:

opt.PositionConcentration.with_equal_bounds(-0.002, 0.002)