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

Author