Just wanted to share a solution for using custom libraries added to QuantConnect locally within VSCode. Hope this helps others!

First, see this article for instructions on adding a new library to QuantConnect if you don't know how: https://backtest-rookies.com/2019/03/22/quantconnect-adding-a-library/

Next, replicate the Library folder, and corresponding libraries locally. Personally I'm using Skylight which will automatically pull in the LIbrary folder and libraries. However, you could also manually duplicate a local Library folder with corresponding libraries. When using Skylight, the Library folder will be added alongside your project folders. In my case on Mac/OSX it was added to /Users/cnaccio/QuantConnect/Charles Naccio/Library

Lastly, assuming you're using VSCode with Pylance, open your workspace or project settings file and add the following to the "settings" section:

"python.analysis.extraPaths": [
"/Users/cnaccio/QuantConnect/Charles Naccio/Library/CapitalMastery"
],
"python.autoComplete.extraPaths": [
"/Users/cnaccio/QuantConnect/Charles Naccio/Library/CapitalMastery"
]

This will help ensure your local autocomplet works, and is compatible with running backtests on QuantConnect.

Below, I'm using a BrokerageModels.py file/module from my custom "CapitalMastery" QuantConnect Library, which contains a TradeZeroBrokerageModel class

# My Projects/BigGap/main.py

# Python Packages
from QuantConnect.Orders.Fees import ConstantFeeModel
from System import DayOfWeek, TimeSpan
from datetime import datetime, timedelta
from typing import Dict, List

# QuantConnect Packages
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Algorithm.Framework import Selection
from QuantConnect.Brokerages import *
from QuantConnect.Algorithm.Framework import *
from QuantConnect.Securities import PatternDayTradingMarginModel, Security
from QuantConnect.Data.UniverseSelection import CoarseFundamental, SecurityChanges
from QuantConnect.Data.Fundamental import FineFundamental
from QuantConnect.Data.Consolidators import TradeBarConsolidator
from QuantConnect.Data.Market import TradeBar, TradeBars

# Custom Packages
from BrokerageModels import TradeZeroBrokerageModel

class BigGap(QCAlgorithm):

def Initialize(self):

# Backtest Settings
self.SetStartDate(2020, 11, 1)
self.SetEndDate(2020, 11, 18)

# Reality Modeling
self.SetCash(50000)
self.SetBrokerageModel(TradeZeroBrokerageModel())

# Configure coarse/fine universe selection
self.UniverseSettings.Resolution = Resolution.Hour
self.AddUniverse(self.CoarseSelection, self.FineSelection)

# Track symbols
self.symbols:Dict[SymbolData] = {}

Finally, here's the BrokerageModels.py file within my CapitalMastery library

# My Projects/Library/CapitalMastery/BrokerageModels.py

# QuantConnect Packages
from QuantConnect.Brokerages import DefaultBrokerageModel
from QuantConnect.Orders.Fees import ConstantFeeModel
from QuantConnect.Securities import PatternDayTradingMarginModel

# Trade Zero Brokerage Model
class TradeZeroBrokerageModel(DefaultBrokerageModel):

def GetFeeModel(self, security):
return ConstantFeeModel(0)

def GetBuyingPowerModel(self, security):
return PatternDayTradingMarginModel()

 

With everything in place, autocomplete is working as desired; see below.

118619_1606045457.jpg