Back

LEAN: Cannot connect to IB account starting LEAN Engine locally.

I have LEAN installed on my system and changed config.json in the following way in oder to enable live trading with IB:
 

"environment": "live-interactive",

  // interactive brokers configuration
  "ib-account": "DUXXXXXX",
  "ib-user-name": "myusername",
  "ib-password": "mypsw",
  "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,

The connection is not established with messages:

20191021 13:03:16.395 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (4/5) ...
20191021 13:03:18.401 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)
20191021 13:03:18.411 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)
20191021 13:03:18.427 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #9
20191021 13:03:18.427 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #9
20191021 13:04:18.421 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191021 13:04:19.421 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (5/5) ...

 

I am really stuck with this. Could anybody point me what may be wrong. Thank you

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.


Hi landc34 ,

Could you please add more logging information?
We don't see any log output for IBAutomater which is important to understand the 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.


because the target machine actively refused it 127.0.0.1:4002.

wrong port or API connections not allowed?

1

Oh, yes, Michael. It's connected after I start TWS,  wrote in config.json the same port as at the "Global Settings"=> API=>"Socket port", than restart LEAN. 
Is it any way to connect IB without preliminary starting TWS? Any other options how to connect to the account?

0

Hi Micheal,
We cannot really help with incomplete information...

Hi landc34 
TWS is no longer supported with IBAutomater, only IBGateway (offline version)
Lean makes all the work, you just need to run it.

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.


Dear Alexandre.
Unfortunately, there is no other things in the log that can help identify the problem. I debugged the code. Ok. I'll copy the full log at the end of this message. (That is after just starting Lean Launcher with configuration above, no TWS in background)
I was able to connect live data only after starting TWS and writing the same port. Agree, it's not convinient... If there is any other way to do live trading with IB, I will be very appriciate if you point me to documentation. Did I changed config.json properly? Why it is not working?

<full log>

20191027 21:24:10.420 Trace:: Config.GetValue(): debug-mode - Using default value: False
20191027 21:24:10.429 Trace:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20191027 21:24:10.434 Trace:: Config.Get(): Configuration key not found. Key: composer-dll-directory - Using default value: C:\Work\Advisors\QuantConnect\Lean\Launcher\bin\Debug\
20191027 21:24:12.978 Trace:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20191027 21:24:12.981 Trace:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20191027 21:24:12.990 Trace:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: ../../../Data/
20191027 21:24:12.992 Trace:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.4.0.0 Mode: DEBUG (64bit)
20191027 21:24:12.993 Trace:: Engine.Main(): Started 9:24 PM
20191027 21:24:12.997 Trace:: Config.GetValue(): job-project-id - Using default value: 0
20191027 21:24:12.999 Trace:: Config.Get(): Configuration key not found. Key: algorithm-path-python - Using default value: ../../../Algorithm.Python/
20191027 21:24:13.003 Trace:: Config.GetValue(): regression-update-statistics - Using default value: False
20191027 21:24:13.004 Trace:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value: LocalLeanManager
20191027 21:24:13.059 Trace:: Config.Get(): Configuration key not found. Key: cloud-api-url - Using default value: https://www.quantconnect.com/api/v2/
20191027 21:24:13.099 Trace:: JobQueue.NextJob(): Selected ../../../Algorithm.Python/BasicTemplateFrameworkAlgorithm.py
20191027 21:24:15.894 Trace:: Python for .NET Assembly: Python.Runtime, Version=1.0.5.26, Culture=neutral, PublicKeyToken=null
20191027 21:24:16.666 Trace:: Python for .NET Assembly: nPython, Version=1.0.5.26, Culture=neutral, PublicKeyToken=null
20191027 21:24:21.863 Trace:: Config.GetValue(): ignore-version-checks - Using default value: False
20191027 21:24:21.868 Trace:: Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 20
20191027 21:24:21.926 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized.
20191027 21:24:22.408 Trace:: PythonInitializer.Initialize(): start...
PythonEngine.Initialize(): Runtime.Initialize()...
Runtime.Initialize(): Py_Initialize...
Runtime.Initialize(): PyEval_InitThreads...
Runtime.Initialize(): Initialize types...
Runtime.Initialize(): Initialize types end.
Runtime.Initialize(): AssemblyManager.Initialize()...
Runtime.Initialize(): AssemblyManager.UpdatePath()...
PythonEngine.Initialize(): register atexit callback...
PythonEngine.Initialize(): GetCLRModule()...
PythonEngine.Initialize(): clr GetManifestResourceStream...
20191027 21:24:28.483 Trace:: PythonInitializer.Initialize(): ended
20191027 21:24:28.522 Trace:: AlgorithmPythonWrapper(): Python version 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]: Importing python module BasicTemplateFrameworkAlgorithm
20191027 21:24:38.929 Trace:: AlgorithmPythonWrapper(): Creating IAlgorithm instance.
20191027 21:24:46.079 Trace:: Config.GetValue(): mute-python-library-logging - Using default value: True
20191027 21:24:46.153 Trace:: Config.Get(): Configuration key not found. Key: ib-version - Using default value: 974
20191027 21:24:46.180 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): Starting IB Automater...
20191027 21:24:46.477 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): StartIBGateway(): starting IBGateway
20191027 21:24:46.579 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): Exception in thread "main" java.lang.NoClassDefFoundError: ibgateway/GWClient
20191027 21:24:46.579 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at ibautomater.IBAutomater.startIBGateway(IBAutomater.java:69)
20191027 21:24:46.582 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at ibautomater.IBAutomater.main(IBAutomater.java:55)
20191027 21:24:46.583 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): Caused by: java.lang.ClassNotFoundException: ibgateway.GWClient
20191027 21:24:46.583 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at java.net.URLClassLoader.findClass(Unknown Source)
20191027 21:24:46.584 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at java.lang.ClassLoader.loadClass(Unknown Source)
20191027 21:24:46.584 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
20191027 21:24:46.585 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at java.lang.ClassLoader.loadClass(Unknown Source)
20191027 21:24:46.585 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     ... 2 more
20191027 21:24:47.707 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterExited(): Exit code: 1
20191027 21:25:46.199 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): IB Automater initialization timeout.
20191027 21:25:46.199 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): IB Automater initialized.
20191027 21:25:46.202 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): Host: 127.0.0.1, Port: 7497, Account: DU1690449, AgentDescription: Individual
20191027 21:25:46.222 Trace:: InteractiveBrokersBrokerage.ResetHandler(): thread started.
20191027 21:25:46.259 Trace:: LiveTradingDataFeed.GetDataQueueHandler(): will use QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage
20191027 21:25:46.264 Trace:: BaseDataExchange(CustomDataExchange) Starting...
20191027 21:25:46.264 Trace:: BaseDataExchange(DataQueueExchange) Starting...
20191027 21:25:46.277 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (1/5) ...
20191027 21:25:50.876 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:7497.    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)
20191027 21:25:50.879 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:7497.    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)
20191027 21:25:50.889 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #24
20191027 21:25:50.889 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #24
20191027 21:26:50.887 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191027 21:26:51.887 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (2/5) ...
20191027 21:26:53.891 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:7497.    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)
20191027 21:26:53.894 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:7497.    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)
20191027 21:26:53.909 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #19
20191027 21:26:53.909 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #19
20191027 21:27:53.901 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191027 21:27:54.902 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (3/5) ...
20191027 21:27:56.904 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:7497.    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)
20191027 21:27:56.909 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:7497.    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)
20191027 21:27:56.928 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #24
20191027 21:27:56.928 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #24
20191027 21:28:56.916 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191027 21:28:57.917 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (4/5) ...
20191027 21:28:59.920 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:7497.    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)
20191027 21:28:59.926 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:7497.    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)
20191027 21:28:59.948 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #26
20191027 21:28:59.948 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #26
20191027 21:29:59.945 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191027 21:30:00.946 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (5/5) ...
20191027 21:30:02.948 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:7497.    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)
20191027 21:30:02.952 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:7497.    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)
20191027 21:30:02.964 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #27
20191027 21:30:02.964 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #27
20191027 21:31:02.963 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191027 21:31:03.097 ERROR:: InteractiveBrokersBrokerage.Connect():  System.TimeoutException: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
   at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Connect() in C:\Work\Advisors\QuantConnect\Lean\Brokerages\InteractiveBrokers\InteractiveBrokersBrokerage.cs:line 680
20191027 21:31:03.124 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized.
20191027 21:31:03.175 ERROR:: Engine.Run():  System.TimeoutException: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
   at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Connect() in C:\Work\Advisors\QuantConnect\Lean\Brokerages\InteractiveBrokers\InteractiveBrokersBrokerage.cs:line 755
   at QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider.Initialize(HistoryProviderInitializeParameters parameters) in C:\Work\Advisors\QuantConnect\Lean\Engine\HistoricalData\BrokerageHistoryProvider.cs:line 53
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Work\Advisors\QuantConnect\Lean\Engine\Engine.cs:line 184
20191027 21:31:03.182 Trace:: JOB HANDLERS:
20191027 21:31:03.182 Trace::          DataFeed:     QuantConnect.Lean.Engine.DataFeeds.LiveTradingDataFeed
20191027 21:31:03.183 Trace::          Setup:        QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler
20191027 21:31:03.183 Trace::          RealTime:     QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler
20191027 21:31:03.184 Trace::          Results:      QuantConnect.Lean.Engine.Results.LiveTradingResultHandler
20191027 21:31:03.184 Trace::          Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler
20191027 21:31:03.185 Trace::          Alpha:        QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler
20191027 21:31:03.185 Trace::          Brokerage:      QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage
20191027 21:31:03.208 Trace:: Waiting for threads to exit...
20191027 21:31:03.225 Trace:: Config.GetValue(): send-via-api - Using default value: False
20191027 21:31:03.228 ERROR:: Algorithm.Initialize() Error: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds. Stack Trace: System.TimeoutException: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
   at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Connect() in C:\Work\Advisors\QuantConnect\Lean\Brokerages\InteractiveBrokers\InteractiveBrokersBrokerage.cs:line 755
   at QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider.Initialize(HistoryProviderInitializeParameters parameters) in C:\Work\Advisors\QuantConnect\Lean\Engine\HistoricalData\BrokerageHistoryProvider.cs:line 53
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Work\Advisors\QuantConnect\Lean\Engine\Engine.cs:line 184
 System.TimeoutException: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
   at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Connect() in C:\Work\Advisors\QuantConnect\Lean\Brokerages\InteractiveBrokers\InteractiveBrokersBrokerage.cs:line 755
   at QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider.Initialize(HistoryProviderInitializeParameters parameters) in C:\Work\Advisors\QuantConnect\Lean\Engine\HistoricalData\BrokerageHistoryProvider.cs:line 53
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Work\Advisors\QuantConnect\Lean\Engine\Engine.cs:line 184
20191027 21:31:03.233 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized.
20191027 21:31:03.316 Trace:: Waiting for threads to exit...
20191027 21:31:03.334 Trace:: LiveTradingResultHandler.Run(): Ending Thread...
20191027 21:31:03.425 Trace:: Waiting for threads to exit...
20191027 21:31:35.768 Trace:: Engine.Run(): Disconnecting from brokerage...
20191027 21:31:35.768 Trace:: InteractiveBrokersBrokerage.Dispose(): Disposing of IB resources.
20191027 21:31:36.399 Trace:: Engine.Run(): Disposing of setup handler...
20191027 21:31:36.399 Trace:: InteractiveBrokersBrokerage.ResetHandler(): thread ended.
20191027 21:31:36.402 Trace:: Engine.Main(): Analysis Completed and Results Posted.
20191027 21:31:36.403 Trace:: LiveTradingDataFeed.Exit(): Start. Setting cancellation token...
20191027 21:31:36.403 Trace:: BaseDataExchange(DataQueueExchange) Stopping...
20191027 21:31:36.403 Trace:: BaseDataExchange(CustomDataExchange) Stopping...
20191027 21:31:36.403 Trace:: LiveTradingDataFeed.Exit(): Exit Finished.
20191027 21:31:36.404 Trace:: LiveTradingDataFeed.GetNextTicksEnumerator(): Exiting enumerator thread...
Engine.Main(): Analysis Complete. Press any key to continue.
20191027 21:31:36.405 Trace:: BaseDataExchange(DataQueueExchange).ConsumeQueue(): Cancellation requested.  Exiting...
20191027 21:31:36.406 Trace:: BaseDataExchange(CustomDataExchange).ConsumeQueue(): Cancellation requested.  Exiting...
 

0

I tried with IBGateway. The behavious is the same as with TWS. If I start IBGateway and login before launching LEAN, the connection is established. If I start just LEAN launcher, nothin happens, it does not start IBGateway. The log below, looks the same. Is it expected behavious? If no, what can be the reason?  JTS folder in config is correct. 

 

20191030 10:58:50.817 Trace:: Config.GetValue(): debug-mode - Using default value: False

20191030 10:58:50.826 Trace:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20191030 10:58:50.828 Trace:: Config.Get(): Configuration key not found. Key: composer-dll-directory - Using default value: C:\Work\Advisors\QuantConnect\Lean\Launcher\bin\Debug\
20191030 10:58:52.901 Trace:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20191030 10:58:52.903 Trace:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20191030 10:58:52.904 Trace:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: ../../../Data/
20191030 10:58:52.904 Trace:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.4.0.0 Mode: DEBUG (64bit)
20191030 10:58:52.904 Trace:: Engine.Main(): Started 10:58 AM
20191030 10:58:52.907 Trace:: Config.GetValue(): job-project-id - Using default value: 0
20191030 10:58:52.908 Trace:: Config.Get(): Configuration key not found. Key: algorithm-path-python - Using default value: ../../../Algorithm.Python/
20191030 10:58:52.909 Trace:: Config.GetValue(): regression-update-statistics - Using default value: False
20191030 10:58:52.910 Trace:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value: LocalLeanManager
20191030 10:58:52.976 Trace:: Config.Get(): Configuration key not found. Key: cloud-api-url - Using default value: https://www.quantconnect.com/api/v2/
20191030 10:58:52.997 Trace:: JobQueue.NextJob(): Selected ../../../Algorithm.Python/BasicTemplateFrameworkAlgorithm.py
20191030 10:58:55.132 Trace:: Python for .NET Assembly: Python.Runtime, Version=1.0.5.26, Culture=neutral, PublicKeyToken=null
20191030 10:58:55.749 Trace:: Python for .NET Assembly: nPython, Version=1.0.5.26, Culture=neutral, PublicKeyToken=null
20191030 10:58:59.628 Trace:: Config.GetValue(): ignore-version-checks - Using default value: False
20191030 10:58:59.630 Trace:: Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 20
20191030 10:58:59.654 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized.
20191030 10:59:00.028 Trace:: PythonInitializer.Initialize(): start...
PythonEngine.Initialize(): Runtime.Initialize()...
Runtime.Initialize(): Py_Initialize...
Runtime.Initialize(): PyEval_InitThreads...
Runtime.Initialize(): Initialize types...
Runtime.Initialize(): Initialize types end.
Runtime.Initialize(): AssemblyManager.Initialize()...
Runtime.Initialize(): AssemblyManager.UpdatePath()...
PythonEngine.Initialize(): register atexit callback...
PythonEngine.Initialize(): GetCLRModule()...
PythonEngine.Initialize(): clr GetManifestResourceStream...
20191030 10:59:05.386 Trace:: PythonInitializer.Initialize(): ended
20191030 10:59:05.403 Trace:: AlgorithmPythonWrapper(): Python version 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]: Importing python module BasicTemplateFrameworkAlgorithm
20191030 10:59:18.227 Trace:: AlgorithmPythonWrapper(): Creating IAlgorithm instance.
20191030 10:59:23.722 Trace:: Config.GetValue(): mute-python-library-logging - Using default value: True
20191030 10:59:23.771 Trace:: Config.Get(): Configuration key not found. Key: ib-version - Using default value: 974
20191030 10:59:23.792 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): Starting IB Automater...
20191030 10:59:24.023 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): StartIBGateway(): starting IBGateway
20191030 10:59:24.085 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): Exception in thread "main" java.lang.NoClassDefFoundError: ibgateway/GWClient
20191030 10:59:24.085 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at ibautomater.IBAutomater.startIBGateway(IBAutomater.java:69)
20191030 10:59:24.087 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at ibautomater.IBAutomater.main(IBAutomater.java:55)
20191030 10:59:24.089 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived(): Caused by: java.lang.ClassNotFoundException: ibgateway.GWClient
20191030 10:59:24.089 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at java.net.URLClassLoader.findClass(Unknown Source)
20191030 10:59:24.089 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at java.lang.ClassLoader.loadClass(Unknown Source)
20191030 10:59:24.090 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
20191030 10:59:24.090 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     at java.lang.ClassLoader.loadClass(Unknown Source)
20191030 10:59:24.091 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterErrorDataReceived():     ... 2 more
20191030 10:59:25.214 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterExited(): Exit code: 1
20191030 11:00:23.803 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): IB Automater initialization timeout.
20191030 11:00:23.803 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): IB Automater initialized.
20191030 11:00:23.805 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): Host: 127.0.0.1, Port: 4002, Account: DU1690449, AgentDescription: Individual
20191030 11:00:23.811 Trace:: InteractiveBrokersBrokerage.ResetHandler(): thread started.
20191030 11:00:23.834 Trace:: LiveTradingDataFeed.GetDataQueueHandler(): will use QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage
20191030 11:00:23.839 Trace:: BaseDataExchange(CustomDataExchange) Starting...
20191030 11:00:23.839 Trace:: BaseDataExchange(DataQueueExchange) Starting...
20191030 11:00:23.848 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (1/5) ...
20191030 11:00:28.386 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)
20191030 11:00:28.391 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)
20191030 11:00:28.401 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #23
20191030 11:00:28.401 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #23
20191030 11:01:28.397 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191030 11:01:29.398 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (2/5) ...
20191030 11:01:31.404 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)
20191030 11:01:31.406 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)
20191030 11:01:31.415 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #10
20191030 11:01:31.415 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #10
20191030 11:02:31.413 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191030 11:02:32.414 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (3/5) ...
20191030 11:02:34.417 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)
20191030 11:02:34.419 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)
20191030 11:02:34.428 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #8
20191030 11:02:34.428 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #8
20191030 11:03:34.426 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191030 11:03:35.427 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (4/5) ...
20191030 11:03:37.432 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)
20191030 11:03:37.433 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)
20191030 11:03:37.442 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #7
20191030 11:03:37.443 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #7
20191030 11:04:37.440 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191030 11:04:38.441 Trace:: InteractiveBrokersBrokerage.Connect(): Attempting to connect (5/5) ...
20191030 11:04:40.447 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)
20191030 11:04:40.451 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)
20191030 11:04:40.470 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread started: #6
20191030 11:04:40.470 Trace:: InteractiveBrokersBrokerage.Connect(): IB message processing thread ended: #6
20191030 11:05:40.468 Trace:: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
20191030 11:05:40.514 ERROR:: InteractiveBrokersBrokerage.Connect():  System.TimeoutException: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
   at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Connect() in C:\Work\Advisors\QuantConnect\Lean\Brokerages\InteractiveBrokers\InteractiveBrokersBrokerage.cs:line 680
20191030 11:05:40.523 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized.
20191030 11:05:40.538 ERROR:: Engine.Run():  System.TimeoutException: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
   at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Connect() in C:\Work\Advisors\QuantConnect\Lean\Brokerages\InteractiveBrokers\InteractiveBrokersBrokerage.cs:line 755
   at QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider.Initialize(HistoryProviderInitializeParameters parameters) in C:\Work\Advisors\QuantConnect\Lean\Engine\HistoricalData\BrokerageHistoryProvider.cs:line 53
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Work\Advisors\QuantConnect\Lean\Engine\Engine.cs:line 184
20191030 11:05:40.543 Trace:: JOB HANDLERS:
20191030 11:05:40.543 Trace::          DataFeed:     QuantConnect.Lean.Engine.DataFeeds.LiveTradingDataFeed
20191030 11:05:40.544 Trace::          Setup:        QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler
20191030 11:05:40.544 Trace::          RealTime:     QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler
20191030 11:05:40.545 Trace::          Results:      QuantConnect.Lean.Engine.Results.LiveTradingResultHandler
20191030 11:05:40.545 Trace::          Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler
20191030 11:05:40.545 Trace::          Alpha:        QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler
20191030 11:05:40.546 Trace::          Brokerage:      QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage
20191030 11:05:40.565 Trace:: Waiting for threads to exit...
20191030 11:05:40.632 Trace:: Config.GetValue(): send-via-api - Using default value: False
20191030 11:05:40.636 ERROR:: Algorithm.Initialize() Error: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds. Stack Trace: System.TimeoutException: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
   at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Connect() in C:\Work\Advisors\QuantConnect\Lean\Brokerages\InteractiveBrokers\InteractiveBrokersBrokerage.cs:line 755
   at QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider.Initialize(HistoryProviderInitializeParameters parameters) in C:\Work\Advisors\QuantConnect\Lean\Engine\HistoricalData\BrokerageHistoryProvider.cs:line 53
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Work\Advisors\QuantConnect\Lean\Engine\Engine.cs:line 184
 System.TimeoutException: InteractiveBrokersBrokerage.Connect(): Operation took longer than 15 seconds.
   at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Connect() in C:\Work\Advisors\QuantConnect\Lean\Brokerages\InteractiveBrokers\InteractiveBrokersBrokerage.cs:line 755
   at QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider.Initialize(HistoryProviderInitializeParameters parameters) in C:\Work\Advisors\QuantConnect\Lean\Engine\HistoricalData\BrokerageHistoryProvider.cs:line 53
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Work\Advisors\QuantConnect\Lean\Engine\Engine.cs:line 184
20191030 11:05:40.649 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized.
20191030 11:05:40.674 Trace:: Waiting for threads to exit...
20191030 11:05:40.752 Trace:: LiveTradingResultHandler.Run(): Ending Thread...
20191030 11:05:40.782 Trace:: Waiting for threads to exit...
20191030 11:06:13.118 Trace:: Engine.Run(): Disconnecting from brokerage...
20191030 11:06:13.118 Trace:: InteractiveBrokersBrokerage.Dispose(): Disposing of IB resources.
20191030 11:06:13.396 Trace:: Engine.Run(): Disposing of setup handler...
20191030 11:06:13.396 Trace:: InteractiveBrokersBrokerage.ResetHandler(): thread ended.
20191030 11:06:13.397 Trace:: Engine.Main(): Analysis Completed and Results Posted.
20191030 11:06:13.401 Trace:: LiveTradingDataFeed.Exit(): Start. Setting cancellation token...
20191030 11:06:13.401 Trace:: BaseDataExchange(DataQueueExchange) Stopping...
20191030 11:06:13.402 Trace:: LiveTradingDataFeed.GetNextTicksEnumerator(): Exiting enumerator thread...
20191030 11:06:13.402 Trace:: BaseDataExchange(CustomDataExchange) Stopping...
20191030 11:06:13.402 Trace:: LiveTradingDataFeed.Exit(): Exit Finished.
20191030 11:06:13.403 Trace:: BaseDataExchange(DataQueueExchange).ConsumeQueue(): Cancellation requested.  Exiting...
Engine.Main(): Analysis Complete. Press any key to continue.
20191030 11:06:13.406 Trace:: BaseDataExchange(CustomDataExchange).ConsumeQueue(): Cancellation requested.  Exiting...
 

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