A lot of the code I use in numerous algorithms call a "has_open_orders" function as follows:
if has_open_orders(data,context) == True:
log.info('Has open orders, not rebalancing.')
def has_open_orders(data,context):
# Only rebalance when we have zero pending orders.
has_orders = False
for stk in data:
orders = get_open_orders(stk)
if orders:
for oo in orders:
message = 'Open order for {amount} shares in {stock}'
message = message.format(amount=oo.amount, stock=stk)
print message
has_orders = True
return has_orders
How can I rewrite this function to accomplish the same in the newest version of quantopian?
Thanks
Serge