Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Portfolio Limits

Hello all,

I working on this algo and Im stuck with something that I thought would be relatively simple.

-I want this to buy a total of 31 stocks
- 17 Large cap
- 8 Mid cap
- 6 Small cap
-Every month at rebalance check the portfolio if any stocks are down from their cost basis

-Sell the ones that are down and buy from stock list to replenish portfolio to the 31 stocks.

Im missing the last piece of replenishing portfolio to the 31 stocks.

Im still learning python so im sure thats my limitation here. Any help with coding that piece would be appreciated.