Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Help a newbie with a Simple MACD

What I have here is a simple MACD that picks out the .head(25) of the highest volume stocks of the day. Just trying things out as I'm still new to Python/Pandas/etc.

At the end of the algorithm I end up with a portfolio of 75 long/short positions, which is 3 times as many positions as I'm supposed to be holding.

I'd like to ask the following:
1. A lot of orders fail to fill. Why is that? Is there a way to stop that happening?
2. Is there a way to have an order that failed be placed again on the next day? Because of the way I've set up the buy/sell signals, they only occur right when the MACD crosses the signal line. So if one of the orders fails, I'm stuck with that position.
3. The leverage constantly increases in this algorithm. I'm assuming it's because of the increasing number of positions, but could there be any other reason for that?