Hi, I am quite new to using Lean CLI and wanted to try to live paper trade.
I currently have it running on Ubuntu 20.10 and in a VM
I installed docker, Lean, and pulled my algos from the cloud, However, when I try to live paper trade using Interactive Brokers, I get the error:
Loader.TryCreatePythonAlgorithm(): System.Exception: AlgorithmPythonWrapper():
NameError: name ‘QCAlgorithm’ is not defined
at <module>
class testalgo(QCAlgorithm):
Is there something wrong with my code?
from QuantConnect import *
from QuantConnect.Data.UniverseSelection import *
import math
import numpy as np
import pandas as pd
import scipy as sp
class testalgo(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2010, 3, 1) #Set Start Date
#self.SetEndDate(2021, 5, 1) #Set Start Date
self.cap = 1000
self.SetCash(self.cap)
def OnData(self):
self.SetHoldings('SPY', 1)
Any help is appreciated, Thanks
Jasper van Merle
Hi Jimothy,
When running LEAN locally you need to add imports for all types that your code references. In this case, you are missing a `from QuantConnect.Algorithm import QCAlgorithm` import. You can find the full list of imports that are automatically applied in the cloud in the CLI documentation.
Jimothy
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!