From a90e7956958c6bcb63101f65c91d442ceaf10c83 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Wed, 21 Apr 2021 09:37:16 +0300 Subject: [PATCH] Warn and trim custom sell reason if it is too long. --- freqtrade/strategy/interface.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 74e92f389..435ac3ed3 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -572,12 +572,14 @@ class IStrategy(ABC, HyperStrategyMixin): trade.pair, trade, date, current_rate, current_profit) if custom_reason: sell_signal = SellType.CUSTOM_SELL - if isinstance(custom_reason, bool): - custom_reason = None - elif isinstance(custom_reason, str): + if isinstance(custom_reason, str): if len(custom_reason) > CUSTOM_SELL_MAX_LENGTH: - raise OperationalException('Custom sell reason returned ' - 'from custom_sell is too long.') + logger.warning(f'Custom sell reason returned from custom_sell is too ' + f'long and was trimmed to {CUSTOM_SELL_MAX_LENGTH} ' + f'characters.') + custom_reason = custom_reason[:CUSTOM_SELL_MAX_LENGTH] + else: + custom_reason = None # TODO: return here if sell-signal should be favored over ROI # Start evaluations