Hi, what is the docker command that "lean backtest" command runs? I'm trying to run it manually so I can configure it with other docker services. I tried to get the "docker run" command with the tool mentioned here which gives me the following, but it didn't give the same output.
docker run `
--name=lean_cli_vsdbg `
--hostname=COMPUTER-01 `
--mac-address=02:a2:cf:81:00:02 `
--env=DOTNET_NOLOGO=true `
--env=DOTNET_CLI_TELEMETRY_OPTOUT=true `
--env=PATH=/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin `
--env=DEBIAN_FRONTEND=teletype `
--env=LANG=en_US.UTF-8 `
--env=LANGUAGE=en_US:en `
--env=LC_ALL=en_US.UTF-8 `
--env=CONDA=Miniconda3-4.5.12-Linux-x86_64.sh `
--env=PIP_DEFAULT_TIMEOUT=120 `
--env=PYTHONNET_PYDLL=/opt/miniconda3/lib/libpython3.6m.so `
--volume='C:\Projects\lean-cloud\data:/Lean/Data:rw' `
--volume='C:\Projects\lean-cloud\proj\backtests\2021-06-08_21-38-27:/Results:rw' `
--volume='C:\Projects\lean-cloud\proj\storage:/Storage:rw' `
--volume='C:\Users\user\AppData\Local\Temp\lean-cli-chpf547q:/LeanCLI:rw' `
--volume=lean_cli_nuget:/root/.nuget/packages:rw `
--volume=/Lean/Data `
--volume=/LeanCLI `
--volume=/Results `
--volume=/Storage `
--volume=/root/.nuget/packages `
--workdir=/Lean/Launcher/bin/Debug `
--detach=true `
-t quantconnect/lean:latest
One suggestion: If you can include the "docker run" command in the --verbose switch that would be great.
Thanks,
Omid
Jasper van Merle
Hi Omid,
The CLI communicates with the Docker client via Docker's Python SDK, meaning it doesn't use `docker run`. The configuration you see with `--verbose` is for this Python SDK. If you were to manually translate this configuration to `docker run` format I think this matches it for a C# project (assuming `Username` is your username and `C:/Projects/LeanCLI` the directory generated by `lean init`):
As you know, the temporary directories that are mounted are generated by the CLI for a single backtest only and deleted afterward. If you want to manually run Docker like the CLI runs Docker, you will also have to create those directories/files like the CLI does. The easiest way to learn what's in them is to run `lean backtest --verbose` on a complex algorithm so you have time to copy the temporary directories shown in the debug logging to another location before they are deleted so you can inspect them further.
Omid Rad
Great, I tried it and it worked with minor modifications. My trick to keep temporary directories from being removed too quickly was to press the pause button on the keyboard after running “lean backtest”. :) I only needed to modify `lean-cli-start.sh` and add `cp /LeanCLI/bin/Debug/*.dll /Lean/Launcher/bin/Debug/` to it after `dotnet build` line, otherwise I got a FileNotFoundException. I don't know how it works in Lean CLI without copying project DLL to the Launcher's bulid path.
Jasper van Merle
Hi Omid,
The CLI generates a custom .csproj file before building C# projects. In this .csproj file `OutputPath` is set to `/Lean/Launcher/bin/Debug` and `CopyLocalLockFileAssemblies` is set to true, so running `dotnet build` automatically places the DLL files for the project and all referenced libraries in that directory. You can find the full contents of the generated .csproj file on GitHub.
Omid Rad
Excellent! Thanks so much for your help. 👍
Omid Rad
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!