Projects

Shared Libraries

Introduction

Project libraries are QuantConnect projects you can merge into your project to avoid duplicating code files. If you have tools that you use across several projects, create a library.

Create Libraries

Follow these steps to create a library:

  1. Open a project.
  2. In the left navigation menu, click the VS Code QuantConnect icon QuantConnect icon.
  3. In the Project panel, click Add Library.
  4. Click Create New.
  5. In the Input Library Name field, enter a name for the library.
  6. Click Create Library.
  7. The template library files are added to a new project in the Library directory in your organization workspace.

  8. In the left navigation menu, click the Local Platform explorer icon Explorer icon.
  9. In Explorer panel, open the Library.pyLibrary.cs file and implement your library.

Add Libraries

Follow these steps to add a library to your project:

  1. Open the project.
  2. In the left navigation menu, click the QuantConnect icon.
  3. In the Project panel, click Add Library.
  4. Click the Choose a library... field and then click a library from the drop-down menu.
  5. Click Add Library (e.g. Calculators).
  6. The library files are added to your project. To view the files, in the right navigation menu, click the Explorer icon.

  7. Import the library into your project to use the library.
  8. using Calculators;
    namespace QuantConnect.Algorithm.CSharp
    {
        public class AddLibraryAlgorithm : QCAlgorithm
        {
            private TaxesCalculator _taxesCalculator = new();
        }
    }
    from Calculators.TaxesCalculator import TaxesCalculator
    class AddLibraryAlgorithm(QCAlgorithm):
        taxes_calculator = TaxesCalculator()

Rename Libraries

To rename a library, open the library project file and then rename the project.

Remove Libraries

Follow these steps to remove a library from your project:

  1. Open the project that contains the library you want to remove.
  2. In the left navigation menu, click the QuantConnect icon.
  3. In the Project panel, hover over the library name and then click the trash can icon that appears.
  4. Delete a library from a project

    The library files are removed from your project.

Delete Libraries

To delete a library, delete the library project file.

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: