Projects
Cloud Synchronization
Introduction
Cloud synchronization allows you to synchronize your projects on QuantConnect.com with your local drive using the Lean CLI. Cloud synchronization makes it possible to use your local development environment when writing your algorithms while using QuantConnect's infrastructure and data library when executing them.
Pulling Cloud Projects
Follow these steps to pull all your cloud projects to your local drive:
- Log in to the CLI if you haven't done so already.
- Open a terminal in your CLI root directory.
- Run
lean cloud pull
to pull all your cloud projects to the current directory, creating directories where necessary.$ lean cloud pull [1/3] Pulling 'Creative Red Mule' Successfully pulled 'Creative Red Mule/main.py' [2/3] Pulling 'Determined Yellow-Green Duck' Successfully pulled 'Determined Yellow-Green Duck/main.py' Successfully pulled 'Determined Yellow-Green Duck/research.ipynb' [3/3] Pulling 'Halloween Strategy' Successfully pulled 'Halloween Strategy/benchmark.py' Successfully pulled 'Halloween Strategy/main.py' Successfully pulled 'Halloween Strategy/research.ipynb'
- Update your projects to include the required imports to run the projects locally and to make autocomplete work.
Follow these steps to pull a single cloud project to your local drive:
- Log in to the CLI if you haven't done so already.
- Open a terminal in your CLI root directory.
- Run
lean cloud pull --project "<projectName>"
to pull the project named "<projectName>" to ./<projectName>.$ lean cloud pull --project "My Project" [1/1] Pulling 'My Project' Successfully pulled 'My Project/main.py' Successfully pulled 'My Project/research.ipynb'
- Update your project to include the required imports to run the project locally and to make autocomplete work.
Pushing Local Projects
Follow these steps to push all your local projects to the cloud:
- Log in to the CLI if you haven't done so already.
- Open a terminal in your CLI root directory.
- Run
lean cloud push
to push all your local projects to the cloud, creating new cloud projects where necessary.$ lean cloud push [1/3] Pushing 'Alpha' Successfully created cloud project 'Alpha' Successfully created cloud file 'Alpha/benchmark.py' Successfully updated cloud file 'Alpha/main.py' Successfully updated cloud file 'Alpha/research.ipynb' [2/3] Pushing 'Buy and Hold BNBUSDT' Successfully created cloud project 'Buy and Hold BNBUSDT' Successfully updated cloud file 'Buy and Hold BNBUSDT/main.py' Successfully updated cloud file 'Buy and Hold BNBUSDT/research.ipynb' [3/3] Pushing 'Creative Red Mule' Successfully updated cloud file 'Creative Red Mule/main.py'
Follow these steps to push a single local project to the cloud:
- Log in to the CLI if you haven't done so already.
- Open a terminal in your CLI root directory.
- Run
lean cloud push --project "<projectName>"
to push the project stored in ./<projectName> to the cloud.$ lean cloud push --project "My Project" [1/1] Pushing 'My Project' Successfully updated cloud file 'My Project/main.py'
Detecting Environment
Sometimes it might be useful to run certain logic only when your algorithm is running locally, or when it is running in the cloud.
You can use the following code snippet to check where your algorithm is running (replace Computer
with your computer's hostname):
using System; if (Environment.MachineName == "Computer") { // Running locally } else { // Running in the cloud }
import platform if platform.node() == "Computer": # Running locally pass else: # Running in the cloud pass