last step: stop loss on exchange added to trailing
This commit is contained in:
parent
6d588b3b0b
commit
cffc9ce890
@ -234,12 +234,9 @@ 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 = self.stop_loss_reached(current_rate=current_rate, trade=trade,
|
||||||
stoplossflag = SellCheckTuple(sell_flag=False, sell_type=SellType.NONE)
|
current_time=date, current_profit=current_profit,
|
||||||
else:
|
force_stoploss=force_stoploss)
|
||||||
stoplossflag = self.stop_loss_reached(current_rate=current_rate, trade=trade,
|
|
||||||
current_time=date, current_profit=current_profit,
|
|
||||||
force_stoploss=force_stoploss)
|
|
||||||
|
|
||||||
if stoplossflag.sell_flag:
|
if stoplossflag.sell_flag:
|
||||||
return stoplossflag
|
return stoplossflag
|
||||||
@ -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:
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user