Back

Connection with Interactive Brokers lost?

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."
 

Update Backtest








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)

0

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)
0

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

0

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.


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.

0

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.

0

It did reconnect. When its disconnected for any prolonged period it

terminates the algorithm.



For anything more specific send an email to support@quantconnect.com
0

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.


Update Backtest





0

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.


Loading...

This discussion is closed