Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Why does trying to get the closing price of VXX any farther back than 20 days give me bad numbers?

It works for within 20 days then anything more gives those outputs.

2 responses

This just made me discover an interesting behavior of the .iloc[] method.

In your code above you call history with a bar_count of 20 days, but you are indexing into the dataframe with .iloc[-21], which I thought would throw an error, but instead it silently returns whatever garbage is in memory at the location you are indexing into.

Make sure that the indexes into the history dataframe are in agreement with the bar_count parameter. The bug I just mentioned will produce total nonsense with no complaints otherwise.

UPDATE: It looks like the issue of negative indexing into memory not owned by the dataframe has been fixed in later versions of Pandas, but it will be an issue on Quantopian until we bump up our version so use caution in the meantime.

Thanks good catch.