I want to place a limit order that will be active for 5 minutes, then it kills the order if not filled in 5 minutes. I can do this without a problem but once I kill the order, I am no longer registering that I have any orders, and so when myfunc() runs again checking for open orders it doesn't detect any and places another trade. myfunc() runs every minute for the first 1hr of trading because that is my Target entry. The problem is I can't halt the entire function because I am running the same logic for all of my universe to determine buying and selling.
def myfunc(context, data):
for stock in context.security_list:
if has_orders(stock):
print('has open orders - doing nothing!')
elif (currentHigh>meanPrice) & (currentLow<meanPrice):
order(stock, sharesToShort,limit_price=entryLimit)#, style=LimitOrder(entryLimit))