Small refactorings, use only enter_long columns
This commit is contained in:
@@ -5,9 +5,9 @@ class SignalType(Enum):
|
||||
"""
|
||||
Enum to distinguish between buy and sell signals
|
||||
"""
|
||||
BUY = "buy" # To be renamed to enter_long
|
||||
SELL = "sell" # To be renamed to exit_long
|
||||
SHORT = "short" # Should be "enter_short"
|
||||
ENTER_LONG = "enter_long"
|
||||
EXIT_LONG = "exit_long"
|
||||
ENTER_SHORT = "enter_short"
|
||||
EXIT_SHORT = "exit_short"
|
||||
|
||||
|
||||
|
@@ -420,7 +420,7 @@ class FreqtradeBot(LoggingMixin):
|
||||
return False
|
||||
|
||||
# running get_signal on historical data fetched
|
||||
(side, enter_tag) = self.strategy.get_enter_signal(
|
||||
(side, enter_tag) = self.strategy.get_entry_signal(
|
||||
pair, self.strategy.timeframe, analyzed_df
|
||||
)
|
||||
|
||||
|
@@ -594,18 +594,18 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
return False, False
|
||||
|
||||
if is_short:
|
||||
enter = latest[SignalType.SHORT] == 1
|
||||
exit_ = latest[SignalType.EXIT_SHORT] == 1
|
||||
enter = latest.get(SignalType.ENTER_SHORT, 0) == 1
|
||||
exit_ = latest.get(SignalType.EXIT_SHORT, 0) == 1
|
||||
else:
|
||||
enter = latest[SignalType.BUY] == 1
|
||||
exit_ = latest[SignalType.SELL] == 1
|
||||
enter = latest[SignalType.ENTER_LONG] == 1
|
||||
exit_ = latest.get(SignalType.EXIT_LONG, 0) == 1
|
||||
|
||||
logger.debug(f"exit-trigger: {latest['date']} (pair={pair}) "
|
||||
f"enter={enter} exit={exit_}")
|
||||
|
||||
return enter, exit_
|
||||
|
||||
def get_enter_signal(
|
||||
def get_entry_signal(
|
||||
self,
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
@@ -624,19 +624,19 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
if latest is None or latest_date is None:
|
||||
return None, None
|
||||
|
||||
enter_long = latest[SignalType.BUY] == 1
|
||||
exit_long = latest[SignalType.SELL] == 1
|
||||
enter_short = latest[SignalType.SHORT] == 1
|
||||
exit_short = latest[SignalType.EXIT_SHORT] == 1
|
||||
enter_long = latest[SignalType.ENTER_LONG.value] == 1
|
||||
exit_long = latest.get(SignalType.EXIT_LONG.value, 0) == 1
|
||||
enter_short = latest.get(SignalType.ENTER_SHORT.value, 0) == 1
|
||||
exit_short = latest.get(SignalType.EXIT_SHORT.value, 0) == 1
|
||||
|
||||
enter_signal: Optional[SignalDirection] = None
|
||||
enter_tag_value: Optional[str] = None
|
||||
if enter_long == 1 and not any([exit_long, enter_short]):
|
||||
enter_signal = SignalDirection.LONG
|
||||
enter_tag_value = latest.get(SignalTagType.BUY_TAG, None)
|
||||
enter_tag_value = latest.get(SignalTagType.BUY_TAG.value, None)
|
||||
if enter_short == 1 and not any([exit_short, enter_long]):
|
||||
enter_signal = SignalDirection.SHORT
|
||||
enter_tag_value = latest.get(SignalTagType.SHORT_TAG, None)
|
||||
enter_tag_value = latest.get(SignalTagType.SHORT_TAG.value, None)
|
||||
|
||||
timeframe_seconds = timeframe_to_seconds(timeframe)
|
||||
|
||||
|
Reference in New Issue
Block a user