From acf3b751f01e6d76722c31ed3d94c5d1140a5b24 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Thu, 12 Sep 2019 01:21:14 +0300 Subject: [PATCH] Log sell_flag, do not log sell_type=SellType.NONE --- freqtrade/strategy/interface.py | 20 +++++++++----------- tests/test_freqtradebot.py | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 1c4b8e669..3c1df276c 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -302,8 +302,8 @@ class IStrategy(ABC): force_stoploss=force_stoploss, high=high) if stoplossflag.sell_flag: - logger.debug(f"{trade.pair} - Stoploss hit. Selling " - f"(sell_type={stoplossflag.sell_type})...") + logger.debug(f"{trade.pair} - Stoploss hit. sell_flag=True, " + f"sell_type={stoplossflag.sell_type}") return stoplossflag # Set current rate to high for backtesting sell @@ -312,30 +312,28 @@ class IStrategy(ABC): experimental = self.config.get('experimental', {}) if buy and experimental.get('ignore_roi_if_buy_signal', False): - logger.debug(f"{trade.pair} - Buy signal still active. Not selling " - f"(sell_type=SellType.NONE)...") + logger.debug(f"{trade.pair} - Buy signal still active. sell_flag=False") return SellCheckTuple(sell_flag=False, sell_type=SellType.NONE) # Check if minimal roi has been reached and no longer in buy conditions (avoiding a fee) if self.min_roi_reached(trade=trade, current_profit=current_profit, current_time=date): - logger.debug(f"{trade.pair} - Required profit reached. Selling " - f"(sell_type=SellType.ROI)...") + logger.debug(f"{trade.pair} - Required profit reached. sell_flag=True, " + f"sell_type=SellType.ROI") return SellCheckTuple(sell_flag=True, sell_type=SellType.ROI) if experimental.get('sell_profit_only', False): logger.debug(f"{trade.pair} - Checking if trade is profitable...") if trade.calc_profit(rate=rate) <= 0: - logger.debug(f"{trade.pair} - Trade is not profitable. Not selling " - f"(sell_type=SellType.NONE)...") + logger.debug(f"{trade.pair} - Trade is not profitable. sell_flag=False") return SellCheckTuple(sell_flag=False, sell_type=SellType.NONE) if sell and not buy and experimental.get('use_sell_signal', False): - logger.debug(f"{trade.pair} - Sell signal received. Selling " - f"(sell_type=SellType.SELL_SIGNAL)...") + logger.debug(f"{trade.pair} - Sell signal received. sell_flag=True, " + f"sell_type=SellType.SELL_SIGNAL") return SellCheckTuple(sell_flag=True, sell_type=SellType.SELL_SIGNAL) # This one is noisy, commented out... -# logger.debug(f"{trade.pair} - Not selling (sell_type=SellType.NONE)...") +# logger.debug(f"{trade.pair} - No sell signal. sell_flag=False") return SellCheckTuple(sell_flag=False, sell_type=SellType.NONE) def stop_loss_reached(self, current_rate: float, trade: Trade, diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 7a74fc333..d34197519 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -1823,7 +1823,7 @@ def test_handle_trade_roi(default_conf, ticker, limit_buy_order, # if ROI is reached we must sell patch_get_signal(freqtrade, value=(False, True)) assert freqtrade.handle_trade(trade) - assert log_has("ETH/BTC - Required profit reached. Selling (sell_type=SellType.ROI)...", + assert log_has("ETH/BTC - Required profit reached. sell_flag=True, sell_type=SellType.ROI", caplog) @@ -1854,7 +1854,7 @@ def test_handle_trade_experimental( patch_get_signal(freqtrade, value=(False, True)) assert freqtrade.handle_trade(trade) - assert log_has("ETH/BTC - Sell signal received. Selling (sell_type=SellType.SELL_SIGNAL)...", + assert log_has("ETH/BTC - Sell signal received. sell_flag=True, sell_type=SellType.SELL_SIGNAL", caplog)