Emsu / prophet

Financial markets analysis framework for programmers
http://prophet.michaelsu.io
BSD 3-Clause "New" or "Revised" License
1.08k stars 122 forks source link

Bug/Unnecessary code in backtest.py #15

Closed z123 closed 9 years ago

z123 commented 9 years ago

There seems to be a bug in this block of code.

timestamps = prices.index.to_series().loc[start:]

# Check if the last day doesn't have data yet
# Like if it was early in the morning
if not timestamps[-1] in prices:
    timestamps = timestamps[:-1]

See https://github.com/Emsu/prophet/blob/master/prophet/backtest.py#L64-L69.

1) That if statement will always pass. When using the in keyword with DataFrames it only checks the columns of the DataFrame. I think what you were trying to do is check the index of the DataFrame.

2) I am not really sure why you are doing this. You grab the timestamps from the prices and then you proceed to check if timestamp[-1] is not in prices (which will never happen).

Emsu commented 9 years ago

@z123 Thanks I'm not really sure why I did that either. I have a hunch timestamps was probably calculated a different way at some point. Anyways, I'll fix that, thanks!

z123 commented 9 years ago

No problem.