Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Upgraded to Quantopian 2 and tweaked the code a little

Update: This was an accidental post. I intended to do a reply which I finally did elsewhere at
https://www.quantopian.com/posts/why-so-much-available-cash-after-using-order-target-percent-stock-1-dot-0

Not much to say. An upgrade to Quantopian 2.
I also added an additional "cancel open orders" for stuck open orders.
I imagine if this were converted to pipeline code for the selection of "basket" of stocks, it would do even better.