Index out of range or too big

Back

Hello can anyone help me figure out why line 107 is causing this error? the list has over 10000items in it so this could be a reason. i've tried to remove duplicates. I copied this from the tutorial library. It won't let me upload the backtest I want. so it might not be line 107 but this is the offending code. 

if len(self.pair_list[0].a_price) != 0:

 

Update Backtest








 
0

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.


Hey Apollos,

So I ran a bunch of debugs on your code and I found some clues as to where the problem might be originating from. Firstly, the length of self.pair_list starts at 11 and gradually decreases to 0. That is what is causing the index out of bounds error when you try to access self.pair_list[0].

There are 2 main lines of code which may be causing this:

self.pair_list = [x for x in self.pair_list if x.cor > self.pair_threshod]

and

self.pair_list.remove(i)

If it is the first line, then it is probably how you are calculating/retrieving x.cor that is causing it.

Also I noticed that the error is date dependent. For example, changing the dates to (2018, 12, 16) to (2019, 12, 16) doesn't throw the error, even though there is enough time for the error to occur in accordance with the inital dates.

Although I was not able to find a solution to your bug. I hope that was of some help. I will keep investigating once I find more time. If I find more information, I will keep you updated.

Best
Rahul

0

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.


Update Backtest





0

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...

This discussion is closed