From 0147b1631aaa78e25037f7e6378325aaec56a0b4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 11 Jul 2018 19:59:30 +0200 Subject: [PATCH] remove optional from selltype --- freqtrade/strategy/interface.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index c5d58dd46..cb8b8873d 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -36,6 +36,7 @@ class SellType(Enum): TRAILING_STOP_LOSS = "trailing_stop_loss" SELL_SIGNAL = "sell_signal" FORCE_SELL = "force_sell" + NONE = "" class IStrategy(ABC): @@ -149,7 +150,7 @@ class IStrategy(ABC): return buy, sell def should_sell(self, trade: Trade, rate: float, date: datetime, buy: bool, - sell: bool) -> Tuple[bool, Optional[SellType]]: + sell: bool) -> Tuple[bool, SellType]: """ This function evaluate if on the condition required to trigger a sell has been reached if the threshold is reached and updates the trade record. @@ -165,7 +166,7 @@ class IStrategy(ABC): if buy and experimental.get('ignore_roi_if_buy_signal', False): logger.debug('Buy signal still active - not selling.') - return (False, None) + return (False, 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): @@ -175,15 +176,15 @@ class IStrategy(ABC): if experimental.get('sell_profit_only', False): logger.debug('Checking if trade is profitable..') if trade.calc_profit(rate=rate) <= 0: - return (False, None) + return (False, SellType.NONE) if sell and not buy and experimental.get('use_sell_signal', False): logger.debug('Sell signal received. Selling..') return (True, SellType.SELL_SIGNAL) - return (False, None) + return (False, SellType.NONE) def stop_loss_reached(self, current_rate: float, trade: Trade, current_time: datetime, - current_profit: float) -> Tuple[bool, Optional[SellType]]: + current_profit: float) -> Tuple[bool, SellType]: """ Based on current profit of the trade and configured (trailing) stoploss, decides to sell or not @@ -223,7 +224,7 @@ class IStrategy(ABC): trade.adjust_stop_loss(current_rate, stop_loss_value) - return (False, None) + return (False, SellType.NONE) def min_roi_reached(self, trade: Trade, current_profit: float, current_time: datetime) -> bool: """