pmorissette / ffn

ffn - a financial function library for Python
pmorissette.github.io/ffn
MIT License
1.9k stars 284 forks source link

np.log can't handle NaN value in to_log_returns() #156

Open Jmarks199 opened 2 years ago

Jmarks199 commented 2 years ago

I feel like I have to be missing something here.. this seems too obvious of an issue.

In to_log_returns() the statement is:

np.log(prices / prices.shift(1))

.shift produces NaN as the first element. Passing this series to np.log() raises TypeError because numpy can't handle the NaN. Am I missing something or is this an actual issue?