Add this line to your regular_allocation() function and it will behave itself:
def regular_allocation(context, data):
if get_open_orders(): return
It should be possible to write a dynamic_order_target_percent function that would take a look at any open orders (including partial fills) and adjust targets accordingly, by cancelling previous orders first rather than adding to them. Until then, the route usually taken is to skip any frame that has open orders, like that.
On another note, I think the code does not spend any of the initial capital, the gains are all fund raising and profit starting with shorts, and those represent a risk just like buying stocks with cash are a risk, so if you take shorting into account in a returns calculation of profit/risk, you may find that effective returns--while positive (it is reasonable code)--are actually quite a bit below the benchmark if I'm not mistaken.
A good start.