Hi,
New QC user here, developing with VS Code. I have installed the QC stubs, but I'm getting an error (i.e. red underline in my Python code) from Pylance that says “Cannot instantiate abstract class SimpleMovingAverage". I've run this code on the cloud platform, so I know it works. Anyone know the issue here ? The offending line:
self._ma = IndicatorExtensions.of( SimpleMovingAverage(self.band_length), self._rsi )
…and the top of my Python source:
from AlgorithmImports import *
from QuantConnect.Indicators import *
Mia Alissi
With:
If you need to use
IndicatorExtensions.of
, ensure that you are using it correctly with a custom indicator or another compatible indicator object. TheSMA
method will automatically handle the creation and updating of theSimpleMovingAverage
for a given symbol and period.Here's an example of how to use the
SMA
method in your algorithm:This approach ensures that the
SimpleMovingAverage
is instantiated and updated correctly within the QuantConnect framework. """Sources: Simple Moving Average - QuantConnect.com, Indicator Extensions S M A With Custom Indicators Regression Algorithm, Custom Indicator With Extension Algorithm, Automatic Indicators - QuantConnect.com, Combining Indicators - QuantConnect.com
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.
Chris Chan
Thanks AI, but your code replacement doesn't work for my case of combining indicators. In future please check your code suggestion against the quantconnect API.
Louis Szeto
Hi Chris
Maybe you can first try to remove
since it might overwrite the Python-wrapped indicator.
If it does not work, please provide the fully related code snippets for further investigation.
Best
Louis
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.
Chris Chan
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!