Hi,
im using IBKR on a daily resolution equity algo.
for placing order i use MarketOnOpenOrder and noticed the order is sent to the broker when the market is closed, therefore the order is invalid with error “Message: Brokerage failed to place order” and the trade is missed.
shouldn't MarketOnOpenOrder orders try to fill when the market is actually open ?
log from 5am 2021-12-11 (saturday):
2021-12-11 05:00:00 New Order Event: Time: 12/11/2021 05:00:00 OrderID: 2 EventID: 1 Symbol: GM Status: Invalid Quantity: 10 Message: Brokerage failed to place order
Thanks
Mak K
Hi Malo,
Could you please provide the lines of code where you handle orders?
Thanks!
However as a first hunch I think you need to subscribe to a smaller resolution than daily data for them to function properly, you could still use daily data for any calculations you are making, to be clear.
MaloKingi
Hi Mak,
thanks for helping out!
using this to open an order inside onData:
order event:
Fred Painchaud
Hi Malo,
Just another hypothesis here. After testing at a lower res as written by Mak, you could check that the MOO order has a proper expiration set by default. It looks like you create it on a Friday, so maybe with default properties, it is set to expire/fire on the next day. If so, you would need to pass the properties as a fourth parameter to MarketOnOpenOrder. I doubt a bit about that hypothesis because many orders are already converted to MOOs by LEAN and it works over weekends (and even holidays as far as I know)…
The other considerations I know are:
Fred
MaloKingi
Thanks Fred,
it seems that the Friday orders submission is exactly on the IBKR maintenance window (img)
when running on a daily resolution, is there a way to delay that order ?
maybe schedule an even to run later on ?
Mak K
Hi Malo,
You could try using any of these functions https://www.guru99.com/python-time-sleep-delay.html to delay events but I am not sure how proper that would be.
Other than that you could also try playing around with these scheduled events;
Maybe something along the lines of if Today is Friday(scheduled event maybe), if there is a trading signal, then do not send an order but set a Variable to True (and save your ticker symbol if you have more than 1) and then have a scheduled event check that variable on monday or sunday or whenever is needed for IBKR to actually process the order on the correct time on a monday market open and reset the variable after it was processed.
CAUTION;
Please test whatever you implement here sufficiently and maybe start by connecting to ibkr papertrading once you have implemented it.
If none of these things solve your problem I would advice sending an email to support@quantconnect.com
Thanks!
MaloKingi
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!