pilwon / node-ib

Interactive Brokers TWS API client library for Node.js
380 stars 133 forks source link

outsideRth #121

Open QuinDennis opened 6 years ago

QuinDennis commented 6 years ago

created an order: o = ib.order.trailingStop, then o.outsideRth=true, but the order 'Allow this order to be triggered outside of regular trading hours' is not checked.

mjheller commented 6 years ago

Theres a possibility I'm wrong havent tested yet but I think IB automatically strips Market Orders and Stop Orders of all after hours commands and only executes them during regular trading hours. Whereas Limit and Stop Limit Orders do not get stripped and work correctly.

tredondo commented 5 years ago

Something like @mjheller said. IB will also send pointless 2019 errors if you set outsideRth: true for contracts that don't have the "outside regular trading hours" concept (e.g. ES):

Attribute 'Outside Regular Trading Hours' is ignored based on the order type and destination. PlaceOrder is now being processed.

If I set outsideRth for STP and TRAIL orders on contracts like RTY, I do see the warning mark:

image

nemozny commented 5 years ago

I just tested outsideRth and it is working correctly, as @meteorpublish illustrated. I am using futures though. I am not 100% sure about the execution, but my MKT order got executed immediately from TWS, even if outside RTH, but for LMT, STP, TRAIL, ... you have to add the outsideRth flag. I presume the API behavior should be the same. The flag is present in TWS, if the order was submitted via API. So as for the original question by @QuinDennis, the flag is working correctly.

nemozny commented 5 years ago

Verified STP LMT, both STP and subsequent LMT triggered outsideRth at 7:00 CT on GC contract, while trading hours start 8:30 CT.