Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Stop orders don't show up in the live trading dashboard?

I think I am going crazy, or stop orders don't show up in the Orders & Fills panel of the live trading dashboard. I am 80% sure the stop orders are being correctly placed, but it's a little worrying that I don't see them active one the web page...

4 responses

Hi Simon, from our monitoring all IB integrations are running smoothly. If you're seeing an issue in the account, could you send us a private note to [email protected] with permission to look at the dashboard? Then we can take a closer look at the orders.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Okay I am seeing them in IB, but not in Quantopian's paper trading, or else I have a bug somewhere that only shows up in Quantopian paper trading but not IB.

I'll email you folks.

It was my bug, possible related to something in Quantopian/zipline which is not obvious, so I'll explain it for posterity:

Periodically I calculate my signals and rebalance my portfolio, and then for some of the assets, issue stop-loss orders at 10% below last price, trailing (ie: for longs, stops never go down, only get tighter). Every handle_data, I monitor the stops, and if they are for less than my current position, perhaps because of late fills, I cancel and replace them.

The key is that to place the stop losses, I use:

orderid = order_target(sid, 0.0, style=StopOrder(stop_price))  

Now, if I place that order immediately after placing my position-resize order, on startup, at least in Quantopian paper trading, my position size is still 0, and here's the key point: that orderid will be valid, but if you call get_order on it, you get a null/invalid order

So, in my handle_data, I was checking all my stop_loss orders, but to prevent the above from crashing my code, I was checking to make sure the order was not null. However, this left a gap in my logic; what if I iterate all the orderids I have, but not all of the orders are valid. I therefore don't update my stops to my new position sizes (from 0 to 1000 shares for instance), so for an entire day, I have no working stop loss orders, and that's why they weren't showing up in the blotter.

The solution is, if any my orderids correspond null/invalid orders, do over the entire stop-setting process, to place brand new stop orders. By this time, since it's a new minute bar, perhaps some of my positional orders have filled, and order_target won't be generating these bogus orders.

Tada!

And there's still a bug - I have to do a do-over if any of the stop orders are bogus. Sigh!