For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
btalib.rsi doesn't work with default index
-
why btalib.rsi doesn't work with the default pandas dataframe indexing
lst = [1864.90, 1867.24, 1863.73, 1841.16, 1772.16] df = pd.DataFrame(lst, columns=['Close']) rsi = btalib.rsi(df.Close, period=2).df print(rsi)
TypeError: 'slice(2, None, None)' is an invalid key
-
@hoopoe
Yes, that's true, btalib does not work with a non-date index. You need a datetime index. It's designed to work with timeseries data.As to why? You'll need to take that up with @backtrader , but seems obvious enough to me.
-
@run-out thanks for your reply. Actually I'm using bta-lib on a data stream so I'm reindexing the dataframe on each incoming message, so any ideas for a better solution ?