For some context, this is a block of code that's executed at the start of the trading day, 2 minutes after the market open:
tStop['perc'] = context.baseNATR*context.positionInfo['finalScore'][pos]*context.natrs[pos]/context.shortLongRatio
tStop['peg'] = context.portfolio.positions[pos].last_sale_price
trigger = tStop['peg']*(1-tStop['perc']/100)
log.info('Placing trailing stop on LONG {}, perc: {}%'.format(pos,tStop['perc']));
tStop['order'] = order_target(pos,0,StopOrder(trigger))
This will ultimately be a simulated trailing stop, however, it fails on the last line with the error:
Attempted to place an order with a limit price of .
Up to this point I've confirmed the security is long in the portfolio, that trigger is a positive number and less than the last known price. If I remove the StopOrder directive I can place the order, however if I change the order to plain order (i.e. order(pos,0,StopOrder(trigger)) it gives the same error. Any thoughts on what the deal is?