I'm following the bootcamp tutorial (T08) and I defined the following class in the code
class selection_data:
def __init__(self):
self.slow = ExponentialMovingAverage(200)
self.fast = ExponentialMovingAverage(50)
def is_ready(self):
return self.slow.is_ready and self.fast.is_ready
def update(self, time, price):
self.fast.update(time, price)
self.slow.update(time, price)
In this example, ExponentialMovingAverage indicator don't have a parameter for “tick”. However, the code is running well. How is this possible?
Mia Alissi
The
ExponentialMovingAverage
class in QuantConnect does not require a "tick" parameter because it is designed to update its value based on the time and price information you provide when calling theUpdate
method.In your
selection_data
class, you have defined twoExponentialMovingAverage
objects,self.slow
andself.fast
, with periods of 200 and 50 respectively. These objects are initialized when you create an instance of theselection_data
class.The
update
method in your class takestime
andprice
as parameters and uses these to update theExponentialMovingAverage
objects. This is done by calling theUpdate
method onself.fast
andself.slow
and passing thetime
andprice
parameters to it.The
is_ready
method checks if bothExponentialMovingAverage
objects are ready by calling theirIsReady
property. This property returnsTrue
if the indicator is ready andFalse
otherwise.Here is the relevant part of your code:
This code is consistent with the examples provided in the QuantConnect forum.
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.
Uhahahaha
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!