Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Has something changed? stop_reached not true when stop order filled

Hi,

I have this code which was working but now no longer reports when the stop order is filled.

         if ( order_id ):  
              stopQty = order_id.amount  
              if ( order_id.stop_reached ):  
                    if ( order_id.filled != stopQty ):  
                        salePrice = context.portfolio.positions[sid].last_sale_price  
                        msg = "{s} {t} STOP order @ {p} waiting to be filled: ordered {o}, filled {f}"  
                        msg = msg.format(s = sid, t = now, p = salePrice, o = stopQty, f = order_id.filled)  
                        log.info(msg)  
                    else:  
                        context.stopFilled = True  
                        msg = "{s} {t} STOP order filled ({o})"  
                        msg = msg.format(s = sid, t = now, o = stopQty)  
                        log.info(msg)

But I'm finding now that order_id.stop_reached is no longer true once order_id.filled == order_id.amount
Has this functionality changed recently?

Thanks,

1 response

Sorry, the logic is working! My fault, I was clearing a variable before I'd finished with it. Please ignore.