Hi,
I am new for LEAN. Just followed below link to install LEAN docker container locally in my Ubuntu (18.0.4) and I am using Pycharm profession edition.
https://github.com/QuantConnect/Lean/blob/master/.idea/readme.md
When I follow the document, run ./run_docker.sh. It always report below error and the LEAN docker engine cannot work. Any comment? Thanks,
Docker image [default: quantconnect/lean:latest]:
Path to Lean config.json [default: ./Launcher/config.json]:
Path to Data directory [default: ./Data]:
Path to Results directory [default: ./Results]:
Path to Python directory [default: ./Algorithm.Python/]:
Would you like to debug C#? (Requires mono debugger attachment) [default: N]:
Would you like to update the Docker Image? [default: Y]:
./run_docker.sh: line 42: cd: ./Launcher/bin/Debug: No such file or directory
./run_docker.sh: line 42: cd: ./Launcher/bin/Debug: No such file or directory
Csharp file at '/QuantConnect.Algorithm.CSharp.dll' does not exist; no CSharp files will be mounted
Error: No such container: LeanEngine
Pulling Docker image: quantconnect/lean:latest
latest: Pulling from quantconnect/lean
Digest: sha256:d61f0e4302316a6ea011785c915aa6e8607f25cb008c5d8c39b62a0950da7739
Status: Image is up to date for quantconnect/lean:latest
docker.io/quantconnect/lean:latest
Launching LeanEngine with command:
docker run --rm --mount type=bind,source=/home/test/Downloads/py_works/Lean/Launcher/config.json,target=/Lean/Launcher/config.json,readonly -v /home/test/Downloads/py_works/Lean/Data:/Data:ro -v /home/test/Downloads/py_works/Lean/Results:/Results --name LeanEngine -p 5678:5678 --expose 6000 --add-host=host.docker.internal:172.17.0.1 -v /home/test/Downloads/py_works/Lean/Algorithm.Python:/Lean/Algorithm.Python quantconnect/lean:latest --data-folder /Data --results-destination-folder /Results --config /Lean/Launcher/config.json
20210405 03:24:42.965 TRACE:: Using /Lean/Launcher/config.json as configuration file
20210405 03:24:43.081 TRACE:: Config.GetValue(): debug-mode - Using default value: False
20210405 03:24:43.081 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20210405 03:24:43.082 TRACE:: Config.Get(): Configuration key not found. Key: composer-dll-directory - Using default value: /Lean/Launcher/bin/Debug/
20210405 03:24:43.133 TRACE:: Python for .NET Assembly: Python.Runtime, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5000fea6cba702dd
20210405 03:24:43.150 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20210405 03:24:43.151 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20210405 03:24:43.151 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: /Data
20210405 03:24:43.151 TRACE:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.5.0.0 Mode: DEBUG (64bit)
20210405 03:24:43.155 TRACE:: Engine.Main(): Started 3:24 AM
20210405 03:24:43.157 TRACE:: Config.GetValue(): job-project-id - Using default value: 0
20210405 03:24:43.160 TRACE:: Config.GetValue(): regression-update-statistics - Using default value: False
20210405 03:24:43.160 TRACE:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value: LocalLeanManager
20210405 03:24:43.161 TRACE:: Python for .NET Assembly: nPython, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null
Unhandled Exception:
System.ArgumentException: An empty file name is not valid.
at System.IO.DirectoryInfo.CheckPath (System.String path) [0x00016] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.IO.DirectoryInfo..ctor (System.String path, System.Boolean simpleOriginalPath) [0x00006] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.IO.DirectoryInfo..ctor (System.String path) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo..ctor(string)
at QuantConnect.Queues.JobQueue.GetAlgorithmLocation () [0x0002d] in <41d0b53762e5410791fa1603d008c57d>:0
at QuantConnect.Queues.JobQueue.NextJob (System.String& location) [0x00000] in <41d0b53762e5410791fa1603d008c57d>:0
at QuantConnect.Lean.Launcher.Program.Main (System.String[] args) [0x0015b] in <b78e47a6a81e4f9abf45d18859b7e34c>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: An empty file name is not valid.
at System.IO.DirectoryInfo.CheckPath (System.String path) [0x00016] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.IO.DirectoryInfo..ctor (System.String path, System.Boolean simpleOriginalPath) [0x00006] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.IO.DirectoryInfo..ctor (System.String path) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo..ctor(string)
at QuantConnect.Queues.JobQueue.GetAlgorithmLocation () [0x0002d] in <41d0b53762e5410791fa1603d008c57d>:0
at QuantConnect.Queues.JobQueue.NextJob (System.String& location) [0x00000] in <41d0b53762e5410791fa1603d008c57d>:0
at QuantConnect.Lean.Launcher.Program.Main (System.String[] args) [0x0015b] in <b78e47a6a81e4f9abf45d18859b7e34c>:0
Jasper van Merle
Hi Henry,
The easiest way to run LEAN locally is by using the CLI, the shell scripts in the LEAN repository will be deprecated soon. I recommend you check out the Getting Started page of the CLI's documentation, which explains how to install the CLI and how to start using it to run LEAN locally.
Henry111
Thanks, Jasper
Does the LEAN CLI need a subscription 'QUANT RESEARCHER' at least, or the free account can also use this LEAN CLI?
Thanks again,
Henry
Jasper van Merle
Hi Henry,
You don't need a QuantConnect subscription to use the CLI. In fact, if you don't use the commands prefixed by "lean cloud" or "lean data download", you don't even need a QuantConnect account at all.
Henry111
Thanks,
I just pip install lean and it works!
I generated some fake data just want to be more familiar with the whole process. I 'lean create-project' a new project and then 'lean backtest' the default main.py. It output some information and save to a 'backtests' folder. Can I use local rerearch tool etc to load the output result and see the graph that I win or loss per day? When I tried to use local research tool like 'api.ReadBacktest()', it need to input project ID and backtest ID, how can I find those IDs?
Thanks,
henry
Henry111
I did some further check, it seems I need to use 'lean report' instead of 'lean research' to show the backtest graph/chart, right? Questions is my OS is ubunt, can it use 'lean report'? When I run it, it has below error:
lean report --backtest-data-source-file ./test_lean/backtests/2021-04-05_21-03-40/main.json
20210406 02:20:39.581 TRACE:: QuantConnect.Report.Main(): Parsing source files...backtest-data-source-file.json,
20210406 02:20:39.750 TRACE:: QuantConnect.Report.Main(): Instantiating report...
20210406 02:20:39.769 TRACE:: QuantConnect.Report.Report(): Processing backtesting orders
20210406 02:20:39.771 TRACE:: QuantConnect.Report.Report(): Processing live orders
20210406 02:20:39.773 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(): GetCLRModule()...
PythonEngine.Initialize(): clr GetManifestResourceStream...
20210406 02:20:40.031 TRACE:: PythonInitializer.Initialize(): ended
20210406 02:20:41.336 TRACE:: QuantConnect.Report.Main(): Starting content compile...
20210406 02:20:41.337 TRACE:: QuantConnect.Report.Compile(): Rendering strategy name...
20210406 02:20:41.337 TRACE:: QuantConnect.Report.Compile(): Rendering description...
20210406 02:20:41.337 TRACE:: QuantConnect.Report.Compile(): Rendering version...
20210406 02:20:41.337 TRACE:: QuantConnect.Report.Compile(): Rendering stylesheet...
20210406 02:20:41.337 TRACE:: QuantConnect.Report.Compile(): Rendering live marker key...
20210406 02:20:41.337 TRACE:: QuantConnect.Report.Compile(): Rendering days live kpi...
20210406 02:20:41.338 TRACE:: QuantConnect.Report.Compile(): Rendering cagr kpi...
20210406 02:20:41.347 TRACE:: QuantConnect.Report.Compile(): Rendering turnover kpi...
20210406 02:20:41.348 TRACE:: QuantConnect.Report.Compile(): Rendering max drawdown kpi...
20210406 02:20:41.349 TRACE:: QuantConnect.Report.Compile(): Rendering sharpe kpi...
20210406 02:20:41.351 TRACE:: QuantConnect.Report.Compile(): Rendering psr kpi...
20210406 02:20:41.353 TRACE:: QuantConnect.Report.Compile(): Rendering ir kpi...
20210406 02:20:41.353 TRACE:: QuantConnect.Report.Compile(): Rendering markets kpi...
20210406 02:20:41.364 TRACE:: QuantConnect.Report.Compile(): Rendering trades per day kpi...
20210406 02:20:41.367 TRACE:: QuantConnect.Report.Compile(): Rendering estimated algorithm capacity...
20210406 02:20:41.367 TRACE:: QuantConnect.Report.Compile(): Rendering monthly return plot...
20210406 02:20:41.748 TRACE:: QuantConnect.Report.Compile(): Rendering cumulative returns...
20210406 02:20:41.991 TRACE:: QuantConnect.Report.Compile(): Rendering annual returns...
20210406 02:20:42.275 TRACE:: QuantConnect.Report.Compile(): Rendering returns per trade...
20210406 02:20:42.542 TRACE:: QuantConnect.Report.Compile(): Rendering asset allocation over time pie chart...
20210406 02:20:42.837 TRACE:: QuantConnect.Report.Compile(): Rendering drawdown plot...
Unhandled Exception:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
at System.Array.InternalArray__get_Item[T] (System.Int32 index) [0x00009] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at (wrapper managed-to-managed) System.DateTime[].System.Collections.Generic.IList`1.get_Item(int)
at System.Collections.ObjectModel.ReadOnlyCollection`1[T].get_Item (System.Int32 index) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at Deedle.Indices.Linear.LinearIndex`1[K].Deedle-Indices-IIndex`1-KeyAt (System.Int64 address) [0x00000] in <5dc18e6b7ffc58e9a74503836b8ec15d>:0
at Deedle.SeriesModule.GetLastKey[K,V] (Deedle.Series`2[K,V] series) [0x00020] in <5dc18e6b7ffc58e9a74503836b8ec15d>:0
at QuantConnect.Report.DrawdownCollection.NormalizeResults (QuantConnect.Packets.BacktestResult backtestResult, QuantConnect.Packets.LiveResult liveResult) [0x000f2] in
<0c83d07cf3fa4b1ebb6c1d2973815641>:0
at QuantConnect.Report.ReportElements.DrawdownReportElement.Render () [0x0002b] in <0c83d07cf3fa4b1ebb6c1d2973815641>:0
at QuantConnect.Report.Report.Compile (System.String& html, System.String& reportStatistics) [0x0004f] in <0c83d07cf3fa4b1ebb6c1d2973815641>:0
at QuantConnect.Report.Program.Main (System.String[] args) [0x00147] in <0c83d07cf3fa4b1ebb6c1d2973815641>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
at System.Array.InternalArray__get_Item[T] (System.Int32 index) [0x00009] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at (wrapper managed-to-managed) System.DateTime[].System.Collections.Generic.IList`1.get_Item(int)
at System.Collections.ObjectModel.ReadOnlyCollection`1[T].get_Item (System.Int32 index) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at Deedle.Indices.Linear.LinearIndex`1[K].Deedle-Indices-IIndex`1-KeyAt (System.Int64 address) [0x00000] in <5dc18e6b7ffc58e9a74503836b8ec15d>:0
at Deedle.SeriesModule.GetLastKey[K,V] (Deedle.Series`2[K,V] series) [0x00020] in <5dc18e6b7ffc58e9a74503836b8ec15d>:0
at QuantConnect.Report.DrawdownCollection.NormalizeResults (QuantConnect.Packets.BacktestResult backtestResult, QuantConnect.Packets.LiveResult liveResult) [0x000f2] in
<0c83d07cf3fa4b1ebb6c1d2973815641>:0
at QuantConnect.Report.ReportElements.DrawdownReportElement.Render () [0x0002b] in <0c83d07cf3fa4b1ebb6c1d2973815641>:0
at QuantConnect.Report.Report.Compile (System.String& html, System.String& reportStatistics) [0x0004f] in <0c83d07cf3fa4b1ebb6c1d2973815641>:0
at QuantConnect.Report.Program.Main (System.String[] args) [0x00147] in <0c83d07cf3fa4b1ebb6c1d2973815641>:0
Error: Something went wrong while running the LEAN Report Creator, see the logs above for more information
Jasper van Merle
Hi Henry,
The CLI is cross-platform, it should work the same on all platforms. The error you posted is a bug in the report creator, I created a PR to fix it here. I recommend subscribing to the PR so you get a notification when it is merged, once that happens you can run the lean report command with the --update flag to use the updated version of the report creator.
Henry111
Hi, Jasper
Thanks for the help, I will wait for the updated version to be released to fix this bug. Hope it will come soon.
Before the bug fix, if there any alternative way to check the backtest result in graph format instead of checking the main.json?
In 'lean research' , it seems can load previous backtest result to analyze, like ''api.ReadBacktest()'', but I don't know how to find out the backtest IP as the parameter for this function.
Thanks,
henry
Jasper van Merle
Hi Henry,
I recommend you check out the CLI's documentation, we have code snippets available for retrieving local backtests and for retrieving cloud backtests in research notebooks.
Alternatively, since all chart data is stored in JSON, you can use any language you want to create your own program that converts the JSON data to pretty charts.
You should however be able to use the report creator already, as long as you run it on a backtest that ran for more than a single day (that's how I reproduced the error). Do you also see the same error from the lean report command if you try to generate a report of a backtest that ran for multiple days?
Henry111
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!