the backtest has resolved by this discussion
https://www.quantconnect.com/forum/discussion/10840/backtest-pre-market-order-submitted-immediately-but-filled-at-9-30/p1now i deploy this code in live env use Interactive Brokers parper acount.
when place order in pre-market got blow message, create Sell Market On Open order
2021-04-16 08:57:26 : New Order Event: Time: 04/16/2021 08:57:25 OrderID: 1 EventID: 1 Symbol: MTSL Status: Submitted Quantity: -2578 Message: Interactive Brokers Order Event
2021-04-16 08:57:26 : Brokerage Warning: Order Message:. SELL 2,578 MTSL NASDAQ.SCM. Warning: your order will not be placed at the exchange until 2021-04-16 09:30:00 US/Eastern. Origin: [Id=3] IBPlaceOrder: MTSL (STK MTSL USD Smart NASDAQ 0 )
how can i fill this type order immediately?
Cool nemo
class ExtendedMarketHoursFillModel(FillModel): def __init__(self, algo): self.algo = algo def Fill(self, parameters): import pytz security = parameters.Security order = parameters.Order utcTime = pytz.timezone("America/New_York").localize(self.algo.Time, is_dst=None).astimezone(pytz.utc) order_event = OrderEvent(order, utcTime, OrderFee.Zero) order_event.FillPrice = security.Price order_event.Status = OrderStatus.Filled order_event.FillQuantity = order.Quantity return Fill(order_event) class Demo(QCAlgorithm): def Initialize(self): self.SetSecurityInitializer(lambda x: x.SetFillModel(ExtendedMarketHoursFillModel(self)))
Derek Melchin
Hi Cool nemo,
Market orders can't be filled outside of RTH. When submitting orders outside of RTH, we can choose from the following order types:
Lean currently supports the filling of Limit and StopLimit orders outside of RTH, but we have an open GitHub Issue to add this functionality for StopMarket orders. Subscribe to our progress here.
Best,
Derek Melchin
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.
Cool nemo
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!