mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Check for closed stoploss-orders first
This commit is contained in:
parent
f5a44e4fc4
commit
a83de241e4
|
@ -679,6 +679,16 @@ class FreqtradeBot:
|
||||||
except InvalidOrderException as exception:
|
except InvalidOrderException as exception:
|
||||||
logger.warning('Unable to fetch stoploss order: %s', exception)
|
logger.warning('Unable to fetch stoploss order: %s', exception)
|
||||||
|
|
||||||
|
# We check if stoploss order is fulfilled
|
||||||
|
if stoploss_order and stoploss_order['status'] == 'closed':
|
||||||
|
trade.sell_reason = SellType.STOPLOSS_ON_EXCHANGE.value
|
||||||
|
trade.update(stoploss_order)
|
||||||
|
# Lock pair for one candle to prevent immediate rebuys
|
||||||
|
self.strategy.lock_pair(trade.pair,
|
||||||
|
timeframe_to_next_date(self.config['ticker_interval']))
|
||||||
|
self._notify_sell(trade, "stoploss")
|
||||||
|
return True
|
||||||
|
|
||||||
# If buy order is fulfilled but there is no stoploss, we add a stoploss on exchange
|
# If buy order is fulfilled but there is no stoploss, we add a stoploss on exchange
|
||||||
if (not trade.open_order_id and not stoploss_order):
|
if (not trade.open_order_id and not stoploss_order):
|
||||||
|
|
||||||
|
@ -699,16 +709,6 @@ class FreqtradeBot:
|
||||||
trade.stoploss_order_id = None
|
trade.stoploss_order_id = None
|
||||||
logger.warning('Stoploss order was cancelled, but unable to recreate one.')
|
logger.warning('Stoploss order was cancelled, but unable to recreate one.')
|
||||||
|
|
||||||
# We check if stoploss order is fulfilled
|
|
||||||
if stoploss_order and stoploss_order['status'] == 'closed':
|
|
||||||
trade.sell_reason = SellType.STOPLOSS_ON_EXCHANGE.value
|
|
||||||
trade.update(stoploss_order)
|
|
||||||
# Lock pair for one candle to prevent immediate rebuys
|
|
||||||
self.strategy.lock_pair(trade.pair,
|
|
||||||
timeframe_to_next_date(self.config['ticker_interval']))
|
|
||||||
self._notify_sell(trade, "stoploss")
|
|
||||||
return True
|
|
||||||
|
|
||||||
# Finally we check if stoploss on exchange should be moved up because of trailing.
|
# Finally we check if stoploss on exchange should be moved up because of trailing.
|
||||||
if stoploss_order and self.config.get('trailing_stop', False):
|
if stoploss_order and self.config.get('trailing_stop', False):
|
||||||
# if trailing stoploss is enabled we check if stoploss value has changed
|
# if trailing stoploss is enabled we check if stoploss value has changed
|
||||||
|
|
Loading…
Reference in New Issue
Block a user