Projects

Cloud Synchronization

Introduction

Cloud synchronization allows you to synchronize your projects in QuantConnect Cloud 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 the cloud projects that you store in an organization to your local drive:

  1. Log in to the CLI if you haven't done so already.
  2. Open a terminal in the organization workspace from which you want to pull projects.
  3. 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'
  4. 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:

  1. Log in to the CLI if you haven't done so already.
  2. Open a terminal in the organization workspace that stores the project.
  3. 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'
  4. Update your project to include the required imports to run the project locally and to make autocomplete work.

If you have a local copy of the project when you pull the project from the cloud, the configuration values of the cloud project overwrite the configuration values of your local copy.

If one of your team members creates a project library, adds it to a project, and then adds you as a collaborator to the project, you can pull the project but not the library. To pull the library as well, your team member must add you as a collaborator on the library project.

Pushing Local Projects

Follow these steps to push all the local projects in an organization workspace to the cloud:

  1. Log in to the CLI if you haven't done so already.
  2. Open a terminal in the organization workspace.
  3. Run lean cloud push to push all your local projects in the organization 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:

  1. Log in to the CLI if you haven't done so already.
  2. Open a terminal in the organization workspace that contains the project you want to push.
  3. 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'

If you create a project on your local machine and push it to the cloud, the lean cloud push command creates the cloud version of the project in the organization that's linked to your current organization workspace.

If you have a cloud copy of the project when you push the project from your local machine, the configuration values of your local project overwrite the configuration values of your cloud copy.

The CLI only pushes the supported file types in your projects.

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

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: