From 476ed938f583c8fd9a01ab02aa8056edbbd51058 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 11 Apr 2023 07:26:38 +0200 Subject: [PATCH] Extract custom_tag limit from interface file --- freqtrade/constants.py | 1 + freqtrade/strategy/interface.py | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 1d12ed8c1..d83072064 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -64,6 +64,7 @@ USERPATH_FREQAIMODELS = 'freqaimodels' TELEGRAM_SETTING_OPTIONS = ['on', 'off', 'silent'] WEBHOOK_FORMAT_OPTIONS = ['form', 'json', 'raw'] FULL_DATAFRAME_THRESHOLD = 100 +CUSTOM_TAG_MAX_LENGTH = 64 ENV_VAR_PREFIX = 'FREQTRADE__' diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 6d4a3036f..3bc766d91 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -10,7 +10,7 @@ from typing import Dict, List, Optional, Tuple, Union import arrow from pandas import DataFrame -from freqtrade.constants import Config, IntOrInf, ListPairsWithTimeframes +from freqtrade.constants import CUSTOM_TAG_MAX_LENGTH, Config, IntOrInf, ListPairsWithTimeframes from freqtrade.data.dataprovider import DataProvider from freqtrade.enums import (CandleType, ExitCheckTuple, ExitType, MarketDirection, RunMode, SignalDirection, SignalTagType, SignalType, TradingMode) @@ -27,7 +27,6 @@ from freqtrade.wallets import Wallets logger = logging.getLogger(__name__) -CUSTOM_EXIT_MAX_LENGTH = 64 class IStrategy(ABC, HyperStrategyMixin): @@ -1118,11 +1117,11 @@ class IStrategy(ABC, HyperStrategyMixin): exit_signal = ExitType.CUSTOM_EXIT if isinstance(reason_cust, str): custom_reason = reason_cust - if len(reason_cust) > CUSTOM_EXIT_MAX_LENGTH: + if len(reason_cust) > CUSTOM_TAG_MAX_LENGTH: logger.warning(f'Custom exit reason returned from ' f'custom_exit is too long and was trimmed' - f'to {CUSTOM_EXIT_MAX_LENGTH} characters.') - custom_reason = reason_cust[:CUSTOM_EXIT_MAX_LENGTH] + f'to {CUSTOM_TAG_MAX_LENGTH} characters.') + custom_reason = reason_cust[:CUSTOM_TAG_MAX_LENGTH] else: custom_reason = '' if (