kieran-mackle / AutoTrader

A Python-based development platform for automated trading systems - from backtesting to optimisation to livetrading.

Home Page:https://kieran-mackle.github.io/AutoTrader/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Range exception index -1 in indicator method unroll_signal_list

fredblockchain opened this issue · comments

Describe the bug
Hi Kieran,
First of all, thanks for the work you've done, I'm currently trying to learn from your indicators,I liked the idea you implemented for swing detection, that's when I found this issue.
It looks a bit too obvious to me, it kind of looks like it would always fail, so maybe I'm doing something wrong.

I detected that the determination of the range for the following FOR loop is starting with 0 and the "signal[i-1]" part is not working because of a negative index during the first iteration:

for i in range(len(signals)):
if signals[i] != signals[i - 1]:
unrolled_signals[i] = signals[i]

Same exception if I try to run it on an indicator (rsi)

To Reproduce

  • I'm testing the indicator class out of Autotrader (in freqtrade).
  • I'm testing on a dataframe with 450 values (plenty of swings).
  • I'm first calling find_swings on price data ( I have to rename each series because first letter in lower case in freqtrade and your class requires Uppercase). This call returns coherent results, no NA values or anything strange
  • Than I call classify_swings, that's when the exception is generated,

Expected behavior
The following modification makes it work, making it start from 1.
for i in range(1, len(signals)):
Results look good

Version of AutoTrader being used
the last one, from this commit

If you need anything, just le me know
Cheers
Fred