Back

Issue with Downloading Data from InteractiveBrokers using ToolBox

Hi,

I'm trying to download historical data from Interactivebrokers using ToolBox. Executing the following in the command line from \Lean\ToolBox\bin\Debug fails (using Yahoo Finance as downloader works, so the problem is likely IB specific):

QuantConnect.ToolBox.exe --app=IBDL --tickers=SPY --resolution=Daily --from-date=20200201-09:30:00 --to-date=20200227-16:00:00

Here is the output:

20200227 16:23:22.378 Trace:: Config.Get(): Configuration key not found. Key: ib-version - Using default value: 974
20200227 16:23:22.539 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): Starting IB Automater...
20200227 16:23:22.880 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): StartIBGateway(): starting IBGateway
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): Exception in thread "main" java.lang.NoClassDefFoundError: ibgateway/GWClient
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): at ibautomater.IBAutomater.startIBGateway(IBAutomater.java:69)
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): at ibautomater.IBAutomater.main(IBAutomater.java:55)
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): Caused by: java.lang.ClassNotFoundException: ibgateway.GWClient
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): at java.net.URLClassLoader.findClass(Unknown Source)
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): at java.lang.ClassLoader.loadClass(Unknown Source)
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): at java.lang.ClassLoader.loadClass(Unknown Source)
20200227 16:23:22.986 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): ... 2 more
20200227 16:23:24.097 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterExited(): Exit code: 1
20200227 16:24:22.565 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): IB Automater initialization timeout.
20200227 16:24:22.565 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): IB Automater initialized.
20200227 16:24:22.566 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): Host: 127.0.0.1, Port: 4002, Account: DU1733589, AgentDescription: Individual
20200227 16:24:22.576 Trace:: InteractiveBrokersBrokerage.ResetHandler(): thread started.
20200227 16:24:22.591 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (1/5) ...
20200227 16:24:27.169 Trace:: InteractiveBrokersBrokerage.HandleError(): RequestId: -1 ErrorCode: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:24:27.177 Trace:: Brokerage.OnMessage(): Information - Code: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:24:27.182 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #12
20200227 16:24:27.182 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #12
20200227 16:24:42.181 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20200227 16:24:43.182 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (2/5) ...
20200227 16:24:45.187 Trace:: InteractiveBrokersBrokerage.HandleError(): RequestId: -1 ErrorCode: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:24:45.188 Trace:: Brokerage.OnMessage(): Information - Code: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:24:45.189 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #14
20200227 16:24:45.190 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #14
20200227 16:25:00.189 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20200227 16:25:01.191 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (3/5) ...
20200227 16:25:03.196 Trace:: InteractiveBrokersBrokerage.HandleError(): RequestId: -1 ErrorCode: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:25:03.196 Trace:: Brokerage.OnMessage(): Information - Code: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:25:03.197 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #16
20200227 16:25:03.197 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #16
20200227 16:25:18.197 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20200227 16:25:19.197 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (4/5) ...
20200227 16:25:21.199 Trace:: InteractiveBrokersBrokerage.HandleError(): RequestId: -1 ErrorCode: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:25:21.200 Trace:: Brokerage.OnMessage(): Information - Code: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:25:21.201 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #18
20200227 16:25:21.201 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #18
20200227 16:25:36.201 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20200227 16:25:37.201 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (5/5) ...
20200227 16:25:39.203 Trace:: InteractiveBrokersBrokerage.HandleError(): RequestId: -1 ErrorCode: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:25:39.204 Trace:: Brokerage.OnMessage(): Information - Code: -1 - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:4002. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port). at IBApi.EClientSocket.createClientStream(String host, Int32 port). at IBApi.EClientSocket.eConnect(String host, Int32 port, Int32 clientId, Boolean extraAuth)
20200227 16:25:39.205 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #20
20200227 16:25:39.205 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #20
20200227 16:25:54.205 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.

Here is my IB configurations:

// interactive brokers configuration
"ib-account": "DUXXXXXX",
"ib-user-name": "XXXXXXXX",
"ib-password": "XXXXXXXX",
"ib-host": "127.0.0.1",
"ib-port": "4002",
"ib-agent-description": "Individual",
"ib-tws-dir": "C:\\Jts",
"ib-trading-mode": "paper",
"ib-enable-delayed-streaming-data": true,

Appreciate if someone can assist in figuring out why this fails?

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.


 

Hey Ashkan,
 

20200227 16:24:27.169 Trace:: InteractiveBrokersBrokerage.HandleError():
RequestId: -1 ErrorCode: -1 - System.Net.Sockets.SocketException (0x80004005):
No connection could be made because the target machine actively refused it 127.0.0.1:4002.

This suggests that your local host port can't connect, possibly due to a firewall or a particular configuration in your machine. Can you check if you can connect to IB with your machine and deploy a live algorithm locally?

Let us know what happens and we can take the next steps to debugging your issue.

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.


Hey Rahul,

Thanks for the reponse. Sorry not sure if I'm following. What do you mean deploy a live algorithm locally? And when you say "connect to IB with your machine", do you mean, just log in to IB Gateway manually? That I have no problem with and can pull data using IB API (not via LEAN).

Thanks,

Ashkan

 

0

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