Tutorials

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:

  1. Log in to the CLI if you haven't done so already.
  2. Open a terminal in the directory you ran lean init in.
  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 directory you ran lean init in.
  3. Run lean cloud pull --project "My Project" to pull the project named "My Project" to ./My Project.
    $ 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.

Pushing local projects

Follow these steps to push all your local projects to the cloud:

  1. Log in to the CLI if you haven't done so already.
  2. Open a terminal in the directory you ran lean init in.
  3. 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:

  1. Log in to the CLI if you haven't done so already.
  2. Open a terminal in the directory you ran lean init in.
  3. Run lean cloud push --project "My Project" to push the project stored in ./My Project 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

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

Did you find this page helpful?

Contribute to the documentation: