From 14d6cdf9b2197518a123c09c38a07a4b76e9cd27 Mon Sep 17 00:00:00 2001 From: hroff-1902 <47309513+hroff-1902@users.noreply.github.com> Date: Sun, 10 Feb 2019 21:52:33 +0300 Subject: [PATCH 1/4] OHLCV should be float for TA-LIB indicators in the strategy Some exchanges (BitMEX) return integer values for Volume field. And sometimes even for OHLC -- same, on BitMEX, since price decrease is 0.5. TA-LIB functions assume floats and fail with exception. Of course, this can be fixed (converted) in ccxt for particular exchange, but TA-LIB will still fail for exchanges for that such a conversion is not implemented in ccxt code. So let's make perform this conversion here in order to be sure our strategy will not crash on a new exchange. --- freqtrade/data/converter.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/freqtrade/data/converter.py b/freqtrade/data/converter.py index 62e9a68f6..6abb87925 100644 --- a/freqtrade/data/converter.py +++ b/freqtrade/data/converter.py @@ -29,6 +29,10 @@ def parse_ticker_dataframe(ticker: list, ticker_interval: str, utc=True, infer_datetime_format=True) + # Some exchanges return int values for volume and even for ohlc. + # Convert them since TA-LIB indicators used in the strategy assume floats and fail with exception... + frame = frame.astype(dtype={'open': 'float', 'high': 'float', 'low': 'float', 'close': 'float', 'volume': 'float'}) + # group by index and aggregate results to eliminate duplicate ticks frame = frame.groupby(by='date', as_index=False, sort=True).agg({ 'open': 'first', From 4dffb17dd6547e5fa97ebd4920fe5cf57dedc99f Mon Sep 17 00:00:00 2001 From: hroff-1902 <47309513+hroff-1902@users.noreply.github.com> Date: Sun, 10 Feb 2019 22:01:46 +0300 Subject: [PATCH 2/4] fix flake --- freqtrade/data/converter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freqtrade/data/converter.py b/freqtrade/data/converter.py index 6abb87925..231aaefca 100644 --- a/freqtrade/data/converter.py +++ b/freqtrade/data/converter.py @@ -31,7 +31,8 @@ def parse_ticker_dataframe(ticker: list, ticker_interval: str, # Some exchanges return int values for volume and even for ohlc. # Convert them since TA-LIB indicators used in the strategy assume floats and fail with exception... - frame = frame.astype(dtype={'open': 'float', 'high': 'float', 'low': 'float', 'close': 'float', 'volume': 'float'}) + frame = frame.astype(dtype={'open': 'float', 'high': 'float', 'low': 'float', 'close': 'float', + 'volume': 'float'}) # group by index and aggregate results to eliminate duplicate ticks frame = frame.groupby(by='date', as_index=False, sort=True).agg({ From 7ed15c64bae75e7e13076a995267ce9efe0284b9 Mon Sep 17 00:00:00 2001 From: hroff-1902 <47309513+hroff-1902@users.noreply.github.com> Date: Sun, 10 Feb 2019 22:13:40 +0300 Subject: [PATCH 3/4] what else? --- freqtrade/data/converter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/data/converter.py b/freqtrade/data/converter.py index 231aaefca..2b8406ff1 100644 --- a/freqtrade/data/converter.py +++ b/freqtrade/data/converter.py @@ -30,8 +30,9 @@ def parse_ticker_dataframe(ticker: list, ticker_interval: str, infer_datetime_format=True) # Some exchanges return int values for volume and even for ohlc. - # Convert them since TA-LIB indicators used in the strategy assume floats and fail with exception... - frame = frame.astype(dtype={'open': 'float', 'high': 'float', 'low': 'float', 'close': 'float', + # Convert them since TA-LIB indicators used in the strategy assume floats + # and fail with exception... + frame = frame.astype(dtype={'open': 'float', 'high': 'float', 'low': 'float', 'close': 'float', 'volume': 'float'}) # group by index and aggregate results to eliminate duplicate ticks From d6c0c107ac7156b1063078649453616c881bc52e Mon Sep 17 00:00:00 2001 From: hroff-1902 <47309513+hroff-1902@users.noreply.github.com> Date: Sun, 10 Feb 2019 22:23:00 +0300 Subject: [PATCH 4/4] fixed flake hmm, even in the comments? --- freqtrade/data/converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/data/converter.py b/freqtrade/data/converter.py index 2b8406ff1..c32338bbe 100644 --- a/freqtrade/data/converter.py +++ b/freqtrade/data/converter.py @@ -30,7 +30,7 @@ def parse_ticker_dataframe(ticker: list, ticker_interval: str, infer_datetime_format=True) # Some exchanges return int values for volume and even for ohlc. - # Convert them since TA-LIB indicators used in the strategy assume floats + # Convert them since TA-LIB indicators used in the strategy assume floats # and fail with exception... frame = frame.astype(dtype={'open': 'float', 'high': 'float', 'low': 'float', 'close': 'float', 'volume': 'float'})