last step: stop loss on exchange added to trailing

This commit is contained in:
misagh 2019-01-16 14:49:47 +01:00
parent 6d588b3b0b
commit cffc9ce890
2 changed files with 11 additions and 8 deletions

View File

@ -234,9 +234,6 @@ class IStrategy(ABC):
current_rate = low or rate current_rate = low or rate
current_profit = trade.calc_profit_percent(current_rate) current_profit = trade.calc_profit_percent(current_rate)
if self.order_types.get('stoploss_on_exchange'):
stoplossflag = SellCheckTuple(sell_flag=False, sell_type=SellType.NONE)
else:
stoplossflag = self.stop_loss_reached(current_rate=current_rate, trade=trade, stoplossflag = self.stop_loss_reached(current_rate=current_rate, trade=trade,
current_time=date, current_profit=current_profit, current_time=date, current_profit=current_profit,
force_stoploss=force_stoploss) force_stoploss=force_stoploss)
@ -281,8 +278,11 @@ class IStrategy(ABC):
trade.adjust_stop_loss(trade.open_rate, force_stoploss if force_stoploss trade.adjust_stop_loss(trade.open_rate, force_stoploss if force_stoploss
else self.stoploss, initial=True) else self.stoploss, initial=True)
# evaluate if the stoploss was hit # evaluate if the stoploss was hit if stoploss is not on exchange
if self.stoploss is not None and trade.stop_loss >= current_rate: if self.stoploss is not None and \
trade.stop_loss >= current_rate and \
not self.order_types.get('stoploss_on_exchange'):
selltype = SellType.STOP_LOSS selltype = SellType.STOP_LOSS
# If Trailing stop (and max-rate did move above open rate) # If Trailing stop (and max-rate did move above open rate)
if trailing_stop and trade.open_rate != trade.max_rate: if trailing_stop and trade.open_rate != trade.max_rate:

View File

@ -1042,6 +1042,9 @@ def test_handle_stoploss_on_exchange_trailing(mocker, default_conf, fee, caplog,
freqtrade = FreqtradeBot(default_conf) freqtrade = FreqtradeBot(default_conf)
# enabling stoploss on exchange
freqtrade.strategy.order_types['stoploss_on_exchange'] = True
# setting stoploss # setting stoploss
freqtrade.strategy.stoploss = -0.05 freqtrade.strategy.stoploss = -0.05