Hi,
I am testing orders on the paper money IB account.
I am running into two issues regarding IB account.
1. The algo restarts every morning around 9:02am. I don't know why? I have the following logs showing consecutive 2 days:
2022-03-08 14:02:00 Launching analysis for L-ee6fa214f4ee2ab74db78867eb63453d with LEAN Engine v2.5.0.0.13694
2022-03-08 14:08:16 Interactive Brokers Brokerage account base currency: USD
2022-03-08 14:08:16 Trading Live!
2022-03-09 14:02:37 BrokerageSetupHandler.Setup(): Open order detected. Creating order tickets for open order MMP with quantity 255. Beware that this order ticket may not accurately reflect the quantity of the order if the open order is partially filled.
2022-03-09 14:02:37 Launching analysis for L-ed8f66cb4a7ee35cf412a306537671c1 with LEAN Engine v2.5.0.0.13699
2022-03-09 14:08:23 Interactive Brokers Brokerage account base currency: USD
2022-03-09 14:08:23 Trading Live!
2. the second issue is related to an open order that I created on 03/08. This order comes back on 03/09 but the tag I have on the order is something else. Because of that, my order logic does not work. Is there a way to recover the tag for any order when we receive the order from IB after the restart?
More details about this open stopLimit order:
2022-03-08 19:12:01 New Order Event: Time: 03/08/2022 19:12:01 OrderID: 2 EventID: 1 Symbol: MMP Status: Submitted Quantity: 255 LimitPrice: 49.86 StopPrice: 49.61 Message: Interactive Brokers Order Event
2022-03-08 19:12:01 Submitted order: Time: 03/08/2022 19:12:01 OrderID: 2 EventID: 1 Symbol: MMP Status: Submitted Quantity: 255 LimitPrice: 49.86 StopPrice: 49.61 Message: Interactive Brokers Order Event
2022-03-08 19:12:01 UpdateSubmittedOrders Entry.StopLimit
def OnOrderEvent(self, orderEvent):
ticket = self.Transactions.GetOrderTicket(orderEvent.OrderId)
order = self.Transactions.GetOrderById(orderEvent.OrderId)
if orderEvent.Status == OrderStatus.Submitted or orderEvent.Status == OrderStatus.UpdateSubmitted:
self.Log(f'Submitted order: {str(orderEvent)}')
self.Log(f'UpdateSubmittedOrders {order.Tag}')
if orderEvent.FillQuantity == 0:
return
if orderEvent.Status == OrderStatus.Filled:
self.Debug(f'{self.Time}: Trade: {ticket.Symbol}, Qty:{ticket.Quantity}, Price:{ticket.AverageFillPrice}, Tag:{ticket.Tag}')
self.Log(f'UpdateFilledOrders: {order}')
On the following day, the open order events comes with Tag of “Stop Price: ¤49.61 Limit Price: ¤49.86” which was not right.
2022-03-09 15:01:56 New Order Event: Time: 03/09/2022 15:01:56 OrderID: 2 EventID: 1 Symbol: MMP Status: Submitted Quantity: 255 LimitPrice: 49.86 StopPrice: 49.61 Message: Interactive Brokers Order Event
2022-03-09 15:01:57 New Order Event: Time: 03/09/2022 15:01:57 OrderID: 2 EventID: 2 Symbol: MMP Status: PartiallyFilled Quantity: 255 FillQuantity: 100 FillPrice: 49.63 USD LimitPrice: 49.86 StopPrice: 49.61 OrderFee: 1 USD Message: Interactive Brokers Order Fill Event - 155 remaining
2022-03-09 15:01:57 New Order Event: Time: 03/09/2022 15:01:57 OrderID: 2 EventID: 3 Symbol: MMP Status: PartiallyFilled Quantity: 255 FillQuantity: 100 FillPrice: 49.63 USD LimitPrice: 49.86 StopPrice: 49.61 Message: Interactive Brokers Order Fill Event - 55 remaining
2022-03-09 15:01:57 New Order Event: Time: 03/09/2022 15:01:57 OrderID: 2 EventID: 4 Symbol: MMP Status: Filled Quantity: 255 FillQuantity: 55 FillPrice: 49.63 USD LimitPrice: 49.86 StopPrice: 49.61 OrderFee: 0.275 USD Message: Interactive Brokers Order Fill Event
2022-03-09 15:01:57 2022-03-09 10:01:56.800064: Trade: MMP, Qty:255.0, Price:49.63, Tag:Stop Price: ¤49.61 Limit Price: ¤49.86 - Interactive Brokers Order Fill Event
2022-03-09 15:01:57 Submitted order: Time: 03/09/2022 15:01:56 OrderID: 2 EventID: 1 Symbol: MMP Status: Submitted Quantity: 255 LimitPrice: 49.86 StopPrice: 49.61 Message: Interactive Brokers Order Event
2022-03-09 15:01:57 UpdateSubmittedOrders Stop Price: ¤49.61 Limit Price: ¤49.86
2022-03-09 15:01:57 UpdateFilledOrders: OrderId: 2 (BrokerId: 5) Filled StopLimit order for 255 units of MMP: Stop Price: ¤49.61 Limit Price: ¤49.86 - Interactive Brokers Order Fill Event at stop 49.61 limit 49.86
Mustafa Oz
I really need help here. This problem above did not happen when I used QC paper trading account. Now I see this issue with IB paper account. Before moving to a live account, I need to figure out this Tag and restart issue. I found out that Lean is using IBAutomator which auto-restarts every day. How come does this auto-restart cause the Algo to restart? this does not happen with IB paper account! I did tons of tests with the QC paper account and expected similar behavior with IB paper account.
Because of the restart of QC Algo, I also lose all the Tags of the open orders which I utilize for order management. How can I recover the Tags? I am open to any suggestions.
Thank You!
Louis Szeto
Hi Mustafa
For live trading issues, please contact support with the attached project and live deployment for further assistance.
Best
Louis
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.
Mustafa Oz
Hi Louis,
I created a support ticket for this issue yesterday:
TICKET #2337c3f401 | March 15, 2022 - 19:32
I'm still waiting for an answer to this ticket.
Thanks
Mustafa Oz
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!