Warn and trim custom sell reason if it is too long.

This commit is contained in:
Rokas Kupstys 2021-04-21 09:37:16 +03:00
parent 1aad128d85
commit a90e795695

View File

@ -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