Noob python coder and can't understand how to set up and store elements in a rolling window
Not sure what I am doing wrong but when I run this code I end up with the error message and I can't figure out how to fix the rolling windows. There is a lot more in this code but the error is located here:
Runtime Error: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the 'NoneType'>) method. Please check out the API documentation.
import numpy as np
#in Initialize
self.legnth = 5
self.SetWarmUp(timedelta(self.legnth))
self.arrary1 = RollingWindow[float](self.legnth)
self.arrary2 = RollingWindow[float](self.legnth)
#in function
if condition:
self.arrary1.Add(x)
else
self.arrary1.Add(y)
if not self.arrary1.IsReady:
return
element2 = np.sum(self.arrary1)
self.arrary2.Add(element2)
if not self.arrary2.IsReady
return
Derek Melchin
Hi Michaelpet17,
Try replacing
with
See the attached backtest for reference. If that doesn't fix the issue, share more of the algorithm so we can reproduce the error.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Michaelpet17
I love you more than you know Derek! That didn't fix the issue but I made a new basic function to sum my array as below and then it worked perfectly. I never would have guessed that's where my issue was so thank you very much I greatly appreciate it!
Michaelpet17
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!