Please forgive the frequent posts as I iron out the final kinks of zipline live!
I’m finding that the context.portfolio object is not updated when one of my stop orders is filled. More specifically, I opened a short position with an MKT order and simultaneously opened a STOP buy order to cover it. The stop order triggered about an hour later. The execution of both orders appeared in flightlog and is confirmed when I query the positions in my account (the order statuses shows as filled, and the short position no longer exists, as it was covered by the stop).
However, within the zipline strategy still running, context.portfolio shows that the short position is still open. This is only corrected when I cancel the strategy and start it again - I assume because the context.portfolio is refreshed every time the strategy starts.
I can replicate this by opening a position in a zipline live strategy with an zipline.api.order() command and then closing it outside of zipline using quantrocket.blotter.place_orders() in a notebook. The closing order executes, but the change in position is not recognized within the zipline strategy in real-time.
Lack of real-time portfolio update is problematic for a number of reasons. Suggestions for workaround?