I have a new algo and I'm running into some issues. From my understanding I need to utilize "handle_data" in order to check for open orders before anymore are placed. I'm rebalancing everyday, but the issue is I don't want to sell all my securities everyday. I want to sell once they trigger a certain indicator and hold the rest until they cross that threshold as well. I'm currently filtering securities on a masked universe and pulling the top 20 from ranking. So say at the start of the day I'm holding 20 positions, but 5 trigger my exit parameters. The following day Instead of placing 20 orders for the top 20, I'd like to place orders 5 orders so I stay within my leverage bounds.
I'd really appreciate any help, an example from another post, etc. would be great!