From a0f897109409e2f18e2c9896507854804e8f0f29 Mon Sep 17 00:00:00 2001 From: Joe Schr Date: Thu, 4 Mar 2021 18:32:23 +0100 Subject: [PATCH] fix(TrailingSL): use integer index instead of `last_updated` I fixed this as discussed, but: - I didn't use `last()` because it's only available for `DatetimeIndex` - I didn't use `.iloc[-1]` because there are a lot of stern warnings in the docs do don't use it and I don't want to confuse less technically aligned user by now using it in an "official" sample - I did use `.iat[-1]` because it's supposed to be fasted by working on the Series of the requested column directly --- user_data/strategies/trailing_sl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_data/strategies/trailing_sl.py b/user_data/strategies/trailing_sl.py index 7ae5548..1c6137e 100644 --- a/user_data/strategies/trailing_sl.py +++ b/user_data/strategies/trailing_sl.py @@ -47,7 +47,7 @@ class TrailingSL(IStrategy): # so we need to get analyzed_dataframe from dp dataframe, last_updated = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe) - relative_sl = dataframe[last_updated][SL_INDICATOR_NAME] + relative_sl = dataframe[SL_INDICATOR_NAME].iat[-1] if (relative_sl is not None): # print("custom_stoploss().relative_sl: {}".format(relative_sl))