remove optional from selltype
This commit is contained in:
parent
49a7c7f08e
commit
0147b1631a
@ -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:
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user