LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
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.
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.
Jing Wu
242.2k
,
Hi Matt,
You could create a class and create the rolling window in the class. Then each symbol is an object. You could store all the objects in a dictionary and update the rolling window with the symbol key. I attached an example for your reference.
4
Matt Vowels
69
,
Jing Wu Thank you so much - very kind of you to provide this example, that's exactly what I was looking for.
When I initially asked the question, I wasn't sure if the Add method allowed for multiple symbols' data to be stored in a similar fashion to how AddEquity works with Portfolio. Anyway, thanks again, that's a great help.
0
Bjorn
1.1k
,
This is really a great example, was also helping me.
Somehow i am having difficulties trying to access the RollingWindow. Actually i thought it should be for the smaWin from the example just symbolData.smaWin[3]. But that seems not to work for me. Guess this is just a stupid mistake from me here, but would be really happy if somebody could help me here...
Trying to access "self.Log(symbolData.smaWin[3])" with the cloned algorithm from above, i get this error message:
24 | 14:06:55:
Runtime Error: ArgumentOutOfRangeException : Must be between 0 and 0
Parameter name: i
Actual value was 3.
at QuantConnect.Indicators.RollingWindow`1[T].get_Item (System.Int32 i) [0x0004c] in <bad781cfbe0a4d3087700d4fb892d638>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <2e7c1c96edae44d496118948ca617c11>:0
at OnData in main.py:line 94
ArgumentOutOfRangeException : Must be between 0 and 0
Parameter name: i
Actual value was 3.
at QuantConnect.Indicators.RollingWindow`1[T].get_Item (System.Int32 i) [0x0004c] in <bad781cfbe0a4d3087700d4fb892d638>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <2e7c1c96edae44d496118948ca617c11>:0 (Open Stacktrace)
0
Jing Wu
242.2k
,
Hi Beaker, it looks like the error lies in the rolling window is not ready. When you try to retrieve the window value with the index, please add a check
if symbolData.smaWin.IsReady: self.Log(symbolData.smaWin[3])
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.
Loading...
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!