Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Spurious NaNs in history()

I'm having trouble where I just get tons of NaNs in my history() requests that I'm fairly sure shouldn't be there. It claims that by default it should be using ffill to fill it in with the most recent previous data. I was mostly able to deal with it by filling in NaNs with nearby values, but sometimes it will give me an entire timeseries without any data. As an example, calling

history(30, '1d', 'close_price')

on the stock "RF", while at the date of 1/1/02, gives me all NaNs. Can someone explain what I might be doing wrong?

2 responses

I got confused by that recently: 'close_price' is not forward filled by default, whereas 'price' is forward filled.

RF (sid 26438) trades between 1993-01-01 and 2004-06-30, but Quantopian's database is from 2002 onwards, so you don't get any data before that date, so history(30, '1d', 'price') will have 28 NaNs in it when called on 2002-01-03.

Try using some different dates see what happens?

Alright, I think that will explain all of my woes. Thank you! :)