refactoring handle_stoploss_on_exchange
This commit is contained in:
parent
e31fa8721f
commit
bfb7121583
@ -652,8 +652,13 @@ class FreqtradeBot(object):
|
|||||||
# if trailing stoploss is enabled we check if stoploss value has changed
|
# if trailing stoploss is enabled we check if stoploss value has changed
|
||||||
# in which case we cancel stoploss order and put another one with new
|
# in which case we cancel stoploss order and put another one with new
|
||||||
# value immediately
|
# value immediately
|
||||||
|
handle_trailing_stoploss_on_exchange(trade, order)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def handle_trailing_stoploss_on_exchange(self, trade: Trade, order):
|
||||||
if trade.stop_loss > order['info']['stopPrice']:
|
if trade.stop_loss > order['info']['stopPrice']:
|
||||||
# we check also if the update is neccesary
|
# we check if the update is neccesary
|
||||||
update_beat = self.strategy.order_types['stoploss_on_exchange_interval']
|
update_beat = self.strategy.order_types['stoploss_on_exchange_interval']
|
||||||
if (datetime.utcnow() - trade.stoploss_last_update).total_seconds() > update_beat:
|
if (datetime.utcnow() - trade.stoploss_last_update).total_seconds() > update_beat:
|
||||||
# cancelling the current stoploss on exchange first
|
# cancelling the current stoploss on exchange first
|
||||||
@ -665,8 +670,6 @@ class FreqtradeBot(object):
|
|||||||
)['id']
|
)['id']
|
||||||
trade.stoploss_order_id = str(stoploss_order_id)
|
trade.stoploss_order_id = str(stoploss_order_id)
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def check_sell(self, trade: Trade, sell_rate: float, buy: bool, sell: bool) -> bool:
|
def check_sell(self, trade: Trade, sell_rate: float, buy: bool, sell: bool) -> bool:
|
||||||
if self.edge:
|
if self.edge:
|
||||||
stoploss = self.edge.stoploss(trade.pair)
|
stoploss = self.edge.stoploss(trade.pair)
|
||||||
|
Loading…
Reference in New Issue
Block a user