I'm installing quantconnect using the devcontainer option that includes all of the quantconnect platform source code, because I want to be able to debug my code and have the debugger step into the platform code.
I have used the lean CLI + the local platform, and the cloud platform before. I'm wondering about how to setup a workflow / what it normally looks like. I'm not sure if there is a way to make my algorithms compatible with all three platforms. Whether running them using the lean cli + local platform, the cloud platform, or the actual lean codebase devcontainer. The main lean github repo mentions local+cloud hybrid workflows and just points to using the CLI, seemingly suggesting if you want to do a hybrid local/cloud workflow, you should use the only use the lean CLI and not the lean devcontainer.
I see a bunch of algorithm files in the Algorithm.CSharp directory in the LEAN devcontainer. They are just a bunch of single .cs files. They don't seem to follow the organization that the lean CLI used. The lean CLI had each algorithm in it's own directory. Each of these directories was called a "project". They had their own .csproj files and auto generated solution files. Also, there was a project directory called "Library" which other algorithms could import from. I could then use "lean cloud push" to push these projects to the cloud. Then I could run these algorithms in live trading.
Mia Alissi
Sure, Kevin. I can help you understand how to set up a workflow with QuantConnect's LEAN CLI and how to make your algorithms compatible with all three platforms: local, cloud, and the actual LEAN codebase devcontainer.
The LEAN CLI supports multiple workflows, ranging from running everything locally to just using your local development environment but keeping all execution in the cloud. You can mix local and cloud features in any way you'd like. Here are some examples of common workflows:
Cloud-focused workflow (local development, cloud execution): You can start programming locally and run backtests in the cloud with
lean cloud backtest "<projectName>" --open --push
whenever there is something to backtest. The--open
flag means that the backtest results are opened in the browser when done, while the--push
flag means that local changes are pushed to the cloud before running the backtest. When you're finished for the moment, runlean cloud push
to push all locally changed files to the cloud (source).Locally-focused workflow (local development, local execution): You can work on your strategy in your local environment and run backtests locally whenever there's something to test. This command runs your strategy in a Docker container containing the same packages as the ones used on QuantConnect.com, but with your own data (source).
Mixed workflow (local development, local debugging, and cloud execution): You can start programming on your strategies locally, debug a strategy in your local development environment, and backtest a strategy by running
lean cloud backtest "<projectName>" --open --push
to push local changes to the cloud, run a backtest in the cloud, and open the results in the browser once finished (source).As for the organization of the algorithm files, the LEAN CLI creates the basic files and folders most editors need to open your source code, provide autocomplete, and enable local debugging. New projects have a specific structure, and each of these directories is called a "project". They have their own .csproj files and auto-generated solution files (source).
You can use the
lean cloud push
command to push local projects to QuantConnect while preserving the directory structure of your local projects. The project's supported files, description, and parameters are pushed to the cloud (source).I hope this helps! Let me know if you have any other questions.
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.
Kevin Wheeler
So what I did was make a script called hardlink.sh with the following contents:mkdir directory-your-lean-engine-dir-is-in/Lean/Algorithm.CSharp/MyAlgos
ln -f .../your-lean-cli-directory/your-project-directory/yourfile1 directory-your-lean-engine-dir-is-in/Lean/Algorithm.CSharp/MyAlgos/yourfile1
ln -f .../your-lean-cli-directory/your-project-directory/yourfile2 directory-your-lean-engine-dir-is-in/Lean/Algorithm.CSharp/MyAlgos/yourfile2This will place hard links to all of your lean CLI code. It will place these hard links all in one directory in your lean engine directory. This approach has the following advantages:-Still works with vscode's git tools
-Has all your own code in one place.
-If you make edits to your files in either location, whether in your lean cli directory or your lean engine directory, the edits will be reflected in both places.
-if you run lean cloud pull, or git pull and one of your files gets replaced, just re-run the script to make sure the hardlinks in your lean engine directory point to the new files
-If you want to build a custom lean image to then run your lean cli against, all you have to do is delete your MyAlgos directory and then you won't have duplicate code errors saying blah blah blah is already defined when you run your lean ClI code against your custom lean engine image. When done, re-run the script and your hard links will be back in your lean engine directory again.Also setup your devcontainer.json file to mount your data like so:
"mounts": [ "source=your-sub-directories/data,target=/Lean/YourNewDataDir,type=bind,consistency=cached",]
And setup the data-folder property in your Launcher/config.json file to point to YourNewDataDir like so:
"data-folder": "../../../YourNewDataDir/",NOTE: read the above about lean cloud pull replacing files and how you'll need to respond.
Kevin Wheeler
In your hardlink.sh file, include the source files you need. Don't include the csproj. Don't just include all files. Only the ones you need.
Kevin Wheeler
Oh, and my script assumes “ln -f” will force create the links and replace any files necessary. Claude AI says that in some environments -f will just suppress warnings but not do the overwrite.
Louis Szeto
Hi Kevin
We only offer custom Lean in the Web IDE for Trading Firm and Institution tiers. You may want to check out the features comparison the pricing page.
Best
Louis
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.
Kevin Wheeler
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!