Hello,
I've been testing live trading with my IB paper account, for some reason, the algorithm always stop at around 5pm with the error shown below, I am sure I didn't attempt to log in from another location. Has anybody experienced the same thing? Do you know how to fix it? Thanks a lot.
"Runtime Error: Connection with Interactive Brokers lost. This could be because of internet connectivity issues or a log in from another location. Stack Trace: System.Exception: Connection with Interactive Brokers lost. This could be because of internet connectivity issues or a log in from another location."
Michael Manus
is that with your own version of lean running on your server?
you cant use a algo and than login with the Android IB app btw. how the algo behaves
that is the same account.......... only to check that (only for informational reason)
Mochunhei
No. I'm not running my own server. I have subscribed the $20/month plan and run the algo on the cloud server. And I am sure I didn't login to any of my accounts (both live and paper accounts) using any device. The algo stopped pretty regularly at around 5:15pm as shown below.
This is my code if anyone wants to know (The logic of this algo doesn't make sense, it is for testing purpose only):
class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2018,2,15) #Set Start Date self.SetEndDate(2018,3,1) #Set End Date self.SetCash(10000) #Set Strategy Cash self.SetWarmUp(30) self.stock = "AAPL" self.AddEquity("SPY", Resolution.Minute) self.AddEquity(self.stock, Resolution.Minute) self.__macd = self.MACD(self.stock, 12, 26, 9, MovingAverageType.Exponential, Resolution.Minute) self.PlotIndicator("MACD", True, self.__macd, self.__macd.Signal) self.PlotIndicator("Stock's moving averages", self.__macd.Fast, self.__macd.Slow) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Cash) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 10), Action(self.EveryDayAfterMarketOpen)) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 70), Action(self.EveryDayAfterMarketOpen)) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 130), Action(self.EveryDayAfterMarketOpen)) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 130), Action(self.EveryDayAfterMarketClose)) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 70), Action(self.EveryDayAfterMarketClose)) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 10), Action(self.EveryDayAfterMarketClose)) def EveryDayAfterMarketOpen(self): self.Log("EveryDay.SPY X min after open: Fired at: {0}".format(self.Time)) if self.Securities["SPY"].Invested: self.MarketOrder("SPY", -1) else: self.MarketOrder("SPY", 1) def EveryDayAfterMarketClose(self): self.Log("EveryDay.SPY X min before close: Fired at: {0}".format(self.Time)) if self.Securities["SPY"].Invested: self.MarketOrder("SPY", -1) else: self.MarketOrder("SPY", 1) def OnData(self, data): if self.IsWarmingUp: return tolerance = 0.0001; holdings = self.Portfolio[self.stock].Quantity signalDeltaPercent = (self.__macd.Current.Value - self.__macd.Signal.Current.Value)/self.__macd.Fast.Current.Value # if our macd is greater than our signal, then let's go long if holdings <= 0 and signalDeltaPercent > tolerance: # 0.01% # longterm says buy as well self.MarketOrder(self.stock, 1) self.Log('MarketOrder: ' + self.stock) # of our macd is less than our signal, then let's go short elif holdings >= 0 and signalDeltaPercent < -tolerance: self.Liquidate(self.stock) self.Log('Liquidate: ' + self.stock)
Jared Broad
IB disconnects all clients daily. LEAN has logic which automatically reconnects. The precise time it disconnects you depends on your account region but US clients are between 12.15am-1am
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.
Mochunhei
Thanks. But my live algo didn't reconnect automatically, Do I have to do any configuration so that it will reconnect? And I am not from the US.
Michael Manus
I am sure they will look into it....
send the reconnect log if you have it to the support. maybe the reconnect limits are set tooo tight.
Jared Broad
terminates the algorithm.
For anything more specific send an email to support@quantconnect.com
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.
Stephen Hyer
I'm having this problem as well. It has happened on a few occasions now. I don't log in anywhere else, and it always happens when the market is closed. I suggest a SetWarmup(int) line in your initialize to make sure you can restart your strategy right away. Typically I can redeploy with no problem. It is inconvinient though, is there a way to ensure more stable connectivity?
Jared Broad
IB had some connection issues over the near year period. Generally, though users have long-term stable algorithms for months at a time due to automatic reconnection logic built into LEAN.
Filing general issues to the forum won't help debug or understand any connectivity issues you're having. We have thousands of stable algorithms so you need to submit a support ticket for 1-1 assistance. Send an email to support@quantconnect.com with the live deployment ID with the issue.
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.
Mochunhei
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!