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.