Keyboard Shortcuts
Likes
Search
buy order at open if market open between a minimum and maximum
I would like to place a buy order that will fill at the open if the open price (or open ask) is between a certain minimum and maximum.
The maximum is easy enough (I think) using a limit on open order.? Can this be successfully used with a price condition for the minimum?? Something like: o = Order() o.action = 'BUY' o.lmtPrice = maximum_entry_price o.totalQuantity = qty o.tif = 'OPG' price_condition = Create(OrderCondition.Price) price_condition.conId = contract.conId price_condition.exchange = 'SMART' price_condition.isMore = True price_condition.triggerMethod = 4 price_condition.price = minimum_entry_price I have used trigger method 4 (bid/ask) on the price condition so that I don't have to wait for a trade to complete before the conditioned logic is evaluated - does that provide any advantage? Can anyone provide comment on whether the above approach will work, issues to consider, or other options? Thanks! |
¿ªÔÆÌåÓýA minimum indicates a sufficiently strong follow on move (from previous day), a maximum prohibits excessively outsized moves. The trading system does significantly better with both a minimum and a maximum price limit when entering at the open.? Though of course, yes, one option is to take the hit, use only a maximum, and just work with a more reliable LOO order. ? I¡¯ve come up with three workarounds, which approximate the required order behaviour.? Each of them is fine, even with their inherent faults, for an EOD trading system (which shouldn¡¯t be so fragile as to require trade entry prices to be at exactly the open price); but they compromise/approximate in different ways, and the differences are just techncially interesting (how does IB really handle price/time conditions in these scenarios). ? The three options I see are: ?
?
? order = Order() order.action = "BUY" price_condition.isConjunctionConnection = False time_condition = Create(OrderCondition.Time) time_condition.isMore = True order.conditions.append(time_condition) # Conditions do not apply outside RTH, and any condition being met will cancel the order ?
? # [Indicative code, untested] order = Order() order.action = "BUY" order.tif = "GTD" order.goodTillDate = datetime.strftime(end_datetime, '%Y%m%d %H:%M:%S ')? # end_datetime = n seconds after the 9:30 order.totalQuantity = quantity price_condition = Create(OrderCondition.Price) order.conditions.append(price_condition) # Conditions do not apply outside RTH ? Unfortunately IB won¡¯t allow conditions to be added to LOO type orders ¨C otherwise that would be a great way to remove the timing aspect of it. ? ? The three options are all a bit rough, and each may be trying too hard! ?I am testing #2 at the moment. ??The system trades infrequently (once or twice a week), so it takes a while to build up a dataset. ? But are there better ways of doing it?? Would love to get others thoughts. ? ? Dave ? ? From: [email protected] <[email protected]> On Behalf Of Hilmar via groups.io
Sent: Friday, July 14, 2023 7:59 AM To: [email protected] Subject: Re: [TWS API] buy order at open if market open between a minimum and maximum ? Why care about a minimum? Your limit-on-open will fill if the current price is below the limit.It's effectively a market order with a maximum. |
What you wish to implement is effectively a stop-limit order to be placed into the market center official opening auction. That is not possible.
LOO/MOO orders are totally special exchange orders, as well as MOC/LOC.? It's not that IBKR somehow reduces their system capability in respect to these by denying clients to attach price and time conditions et cetera, it's just that such capabilities will not work with exchanges.? These orders are executed atomically (even though not necessarily momentarily) at the opening and closing auctions, or "crosses" in Nasdaq speak. They must be submitted some time ahead of their respective daily trade cycle times. The submission time limit differs by exchange, auction kind (open/close) and order type - limit orders are allowed to be submitted closer to the auction in certain circumstances related to the accumulated balance of pre-orders. After some time once they are submitted and before the auction is carried out they also cannot be recalled. Also, no liquid trading on the exchange will happen in respective stocks before the opening auction and after the closing auction. Certainly, you'll realize that any broker-imposed trading conditions would have zero chance of being respected or enforced under this scheme. Further, the idea that you can get an opening print and then quickly submit an OPG order is completely futile because the primary exchange will simply not start trading before the auction is executed, and even though trading may start a few moments earlier on non-primary exchanges and dark pools, by that time no OPG orders will be accepted by the primary exchange (and non-primary liquidity may not be?much better than in the early non-regular trading anyway). -- Best, DS |