Trouble getting LEAN and IB paper trading to run

Back

I've pulled the latest docker image and repo from github and am trying to launch paper trading on my desktop. 

I've configured the config.json file as follows, and have latest IB Gateway logged into the paper trading account when I execute run_docker.bat.

"environment": "live-interactive", // "live-paper", "backtesting", "live-interactive", "live-interactive-iqfeed"

// algorithm class selector
"algorithm-type-name": "algoName",

// Algorithm language selector - options CSharp, FSharp, VisualBasic, Python, Java
"algorithm-language": "Python",

//Physical DLL location
//"algorithm-location": "QuantConnect.Algorithm.CSharp.dll",
"algorithm-location": "../../../Algorithm.Python/algoName.py",


// interactive brokers configuration
"ib-account": "DU----------",
"ib-user-name": "--------",
"ib-password": "------",
"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": false,
"ib-version": "978",

However I get an unhandled exception below. Can anyone point out where I've gone wrong? 

20201001 09:20:33.230 Trace:: Using /Lean/Launcher/config.json as configuration file
20201001 09:20:33.442 Trace:: Config.GetValue(): debug-mode - Using default value: False
20201001 09:20:33.444 Trace:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20201001 09:20:33.447 Trace:: Config.Get(): Configuration key not found. Key: composer-dll-directory - Using default value: /Lean/Launcher/bin/Debug/
20201001 09:20:33.540 Trace:: Python for .NET Assembly: Python.Runtime, Version=1.0.5.30, Culture=neutral, PublicKeyToken=null
20201001 09:20:33.561 Trace:: Python for .NET Assembly: nPython, Version=1.0.5.30, Culture=neutral, PublicKeyToken=null
20201001 09:20:33.580 Trace:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20201001 09:20:33.587 Trace:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20201001 09:20:33.588 Trace:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: /Data
20201001 09:20:33.589 Trace:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.4.0.0 Mode: DEBUG (64bit)
20201001 09:20:33.591 Trace:: Engine.Main(): Started 9:20 AM
20201001 09:20:33.598 Trace:: Config.GetValue(): job-project-id - Using default value: 0
20201001 09:20:33.799 Trace:: Config.GetValue(): regression-update-statistics - Using default value: False
20201001 09:20:33.805 Trace:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value: LocalLeanManager
20201001 09:20:33.812 Trace:: Config.Get(): Configuration key not found. Key: cloud-api-url - Using default value: https://www.quantconnect.com/api/v2/
20201001 09:20:34.563 Trace:: JobQueue.NextJob(): Selected ../../../Algorithm.Python/LIVE_GDX_Overnight.py
20201001 09:20:34.609 Trace:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120
20201001 09:20:34.611 Trace:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18
20201001 09:20:34.612 Trace:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default value: 1440
20201001 09:20:34.627 Trace:: Config.Get(): Configuration key not found. Key: algorithm-id - Using default value: LIVE_GDX_Overnight
20201001 09:20:34.631 Trace:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120
20201001 09:20:34.632 Trace:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18
20201001 09:20:34.634 Trace:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default value: 1440
20201001 09:20:46.652 Trace:: Config.Get(): Configuration key not found. Key: data-permission-manager - Using default value: DataPermissionManager
20201001 09:20:46.656 Trace:: Config.GetValue(): streamed-chart-limit - Using default value: 12
20201001 09:20:46.657 Trace:: Config.GetValue(): streamed-chart-group-size - Using default value: 3
20201001 09:20:46.673 Trace:: Config.Get(): Configuration key not found. Key: object-store-root - Using default value: ./storage
20201001 09:20:46.676 Trace:: Config.GetValue(): ignore-version-checks - Using default value: False
20201001 09:20:46.678 Trace:: AlgorithmManager.CreateTokenBucket(): Initializing LeakyBucket: Capacity: 120 RefillAmount: 18 TimeInterval: 1440
20201001 09:20:46.681 Trace:: Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 20
20201001 09:20:46.691 Trace:: Config.GetValue(): consumer-batching-timeout-ms - Using default value: 0
20201001 09:20:47.192 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...
20201001 09:20:48.680 Trace:: PythonInitializer.Initialize(): ended
20201001 09:20:48.688 Trace:: AlgorithmPythonWrapper(): Python version 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:25:33)
[GCC 7.3.0]: Importing python module LIVE_GDX_Overnight
20201001 09:20:49.595 Trace:: AlgorithmPythonWrapper(): Creating IAlgorithm instance.
20201001 09:20:49.702 ERROR:: LiveTradingResultHandler.Update(): Algorithm not yet initialized.
20201001 09:20:51.692 Trace:: Config.GetValue(): mute-python-library-logging - Using default value: True
20201001 09:20:51.756 Trace:: LocalObjectStore.Initialize(): Storage Root: /Lean/Launcher/bin/Debug/storage/QCAlgorithm
20201001 09:20:51.758 Trace:: LiveTradingDataFeed.GetDataChannelProvider(): will use DataChannelProvider
20201001 09:20:51.798 Trace:: InteractiveBrokersBrokerage.InteractiveBrokersBrokerage(): Starting IB Automater...
20201001 09:20:51.809 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): Setting execute permissions on IBAutomater.sh
20201001 09:20:52.559 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): chmod +x IBAutomater.sh: process exit code: 0
20201001 09:20:52.560 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): Loading IBGateway version: 978
20201001 09:20:52.567 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): IBAutomater process started - Id:19
20201001 09:20:53.470 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): StartIBGateway(): starting IBGateway
20201001 09:20:53.695 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): Exception in thread "main" java.lang.NoClassDefFoundError: ibgateway/GWClient
20201001 09:20:53.698 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): at ibautomater.IBAutomater.startIBGateway(IBAutomater.java:69)
20201001 09:20:53.701 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): at ibautomater.IBAutomater.main(IBAutomater.java:55)
20201001 09:20:53.708 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): Caused by: java.lang.ClassNotFoundException: ibgateway.GWClient
20201001 09:20:53.709 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
20201001 09:20:53.711 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
20201001 09:20:53.712 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
20201001 09:20:53.713 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
20201001 09:20:53.714 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): ... 2 more
20201001 09:20:53.764 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterExited(): Exit code: 1
20201001 09:20:53.767 Trace:: InteractiveBrokersBrokerage.OnIbAutomaterExited(): IBGateway close detected, restarting IBAutomater and reconnecting...

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Disconnect () [0x00000] in <cda8726011a24781a985b8337ca14700>:0
at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.OnIbAutomaterExited (System.Object sender, QuantConnect.IBAutomater.ExitedEventArgs e) [0x00042] in <cda8726011a24781a985b8337ca14700>:0
at QuantConnect.IBAutomater.IBAutomater+<>c__DisplayClass30_0.<Start>b__2 (System.Object sender, System.EventArgs e) [0x00028] in <858cbe6098394df5a11367e438928b42>:0
at System.Diagnostics.Process.OnExited () [0x0003f] in <a360a10e096b4659a9142a244ddaea3e>:0
at System.Diagnostics.Process.RaiseOnExited () [0x0002c] in <a360a10e096b4659a9142a244ddaea3e>:0
at System.Diagnostics.Process.CompletionCallback (System.Object context, System.Boolean wasSignaled) [0x00006] in <a360a10e096b4659a9142a244ddaea3e>:0
at System.Threading.RegisteredWaitHandle.DoCallBack (System.Object timedOut) [0x00008] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.Disconnect () [0x00000] in <cda8726011a24781a985b8337ca14700>:0
at QuantConnect.Brokerages.InteractiveBrokers.InteractiveBrokersBrokerage.OnIbAutomaterExited (System.Object sender, QuantConnect.IBAutomater.ExitedEventArgs e) [0x00042] in <cda8726011a24781a985b8337ca14700>:0
at QuantConnect.IBAutomater.IBAutomater+<>c__DisplayClass30_0.<Start>b__2 (System.Object sender, System.EventArgs e) [0x00028] in <858cbe6098394df5a11367e438928b42>:0
at System.Diagnostics.Process.OnExited () [0x0003f] in <a360a10e096b4659a9142a244ddaea3e>:0
at System.Diagnostics.Process.RaiseOnExited () [0x0002c] in <a360a10e096b4659a9142a244ddaea3e>:0
at System.Diagnostics.Process.CompletionCallback (System.Object context, System.Boolean wasSignaled) [0x00006] in <a360a10e096b4659a9142a244ddaea3e>:0
at System.Threading.RegisteredWaitHandle.DoCallBack (System.Object timedOut) [0x00008] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
Press any key to continue . . .

 

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.


 P Chen Seems you don't have the correct version of IBGateway installed.
If you installed the latest version from IB's website it's probably v980+ but in your config you set v978.

Currently IBAutomater has only been tested with v974 and v978, so I would recommend using one of these versions.
If you need them, you can download the old IBGateway versions for Linux from the QC CDN:
v974: http://cdn.quantconnect.com/interactive/ibgateway-latest-standalone-linux-x64-v974.4g.sh
v978: https://cdn.quantconnect.com/interactive/ibgateway-latest-standalone-linux-x64-v978.1c.sh

 

And windows:

https://cdn.quantconnect.com/interactive/ibgateway-stable-standalone-windows-x64-v978.2c.exe

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 for the rpely Stefano. This is the version I installed however; its 978.2g for Windows:

https://www.interactivebrokers.com.au/en/index.php?f=16457

 

0

978.2g for Windows should work fine, I tested it myself now.

However the stack traces above seem to be from a Linux/Mono setup and you also mentioned Docker.
Are you using our latest DockerfileLeanFoundation or another setup?

https://github.com/QuantConnect/Lean/blob/master/DockerfileLeanFoundation

 

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.


Ah I think I may have gotten confused here....still fairly new to using docker

How am I meant to be using the Lean Foundation docker file? I've done nothing other than install lean and execute the the docker pull command https://hub.docker.com/r/quantconnect/lean and run the run_docker.bat file in the Lean folder after configuring config.json

0

Hi P Chen,

We recommend using the docker image. This is perfectly configured to run out of the box without interfering with your development environment. You can pull this image with

docker pull quantconnect/lean

Refer to the full installation instructions here.

Best,
Derek Melchin

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 Derek but I have pulled the docker image according to the instructions already (as mentioned above). I then run the run_docker.bat file in the Lean folder but get the unhandled exception above. Was I supposed to do something with the DockerfileLeanFoundation docker file as Stefano mentioned first? 

0

Hi Patrick P Chen ,

Sorry about the wait.
I was able to run Lean in live mode with IB inside a docker container.

Since the docker image is Linux, IB Gateway is installed in /roo/Jts, so we need to use the following value:

"ib-tws-dir": "/root/Jts",

 

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