Hi all,
This may be a relatively simple question but when casting a rolling window to a list, do we need to reverse the list so that the most recent data is at index[-1]?
For example:
list = list(self.rollingWindow)
list.reverse()
Regards,
Nick
QUANTCONNECT COMMUNITY
Hi all,
This may be a relatively simple question but when casting a rolling window to a list, do we need to reverse the list so that the most recent data is at index[-1]?
For example:
list = list(self.rollingWindow)
list.reverse()
Regards,
Nick
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.
Fred Painchaud
Hi Nicholas,
In a RollingWindow, the most recent data is at index 0. If in your list you want the most recent data at the end, at index -1, then yes, you need to reverse it.
RollingWindow: most recent 0…-1 least recent.
List: most recent 0…-1 least recent.
Reversed list: least recent 0…-1 most recent.
If your RollingWindow has a large capacity (a lot of data in it, like 500+ or so), and if you do that list(…).reverse() operation often, you would like to consider using a deque instead of a RollingWindow, as your “cast” and your reverse is in O(n) (takes a lot of time considering how fast it could be).
Fred
Nicholas Fitzgerald
Hi Fred,
Thank you for clearing that up, I will have to look into deques and how to use them!
Regards,
Nick
Nicholas Fitzgerald
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!