Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Strange happenings with dropna() and history

The line with r = prices.pct_change().dropna() should drop the first NaN value but it seems to be dropping entire bar labels and prices. I don't know how to explain it but it's very odd from what I'm seeing via the log. I also have to check if securities I reference still exist in history but I thought the history function would return prices for all referenced symbols. I'm just picking and ranking stocks by kelly size but the NaN weirdness prevents my algo from starting until much later. The problem starts from line 77.

2 responses

Maybe prices.pct_change().bfill().ffill()

Looks like I fixed it. Apparently I have to change the axis to 1 to drop specific stocks. prices = prices.dropna(axis=1) works.