Merge pull request #3676 from freqtrade/stoploss_remove_unused_argument

[minor] Cleanup and exception hierarchy documentation
This commit is contained in:
Matthias
2020-08-14 07:11:56 +02:00
committed by GitHub
6 changed files with 53 additions and 26 deletions

View File

@@ -770,7 +770,7 @@ class FreqtradeBot:
logger.debug('Found no sell signal for %s.', trade)
return False
def create_stoploss_order(self, trade: Trade, stop_price: float, rate: float) -> bool:
def create_stoploss_order(self, trade: Trade, stop_price: float) -> bool:
"""
Abstracts creating stoploss orders from the logic.
Handles errors and updates the trade database object.
@@ -833,14 +833,13 @@ class FreqtradeBot:
stoploss = self.edge.stoploss(pair=trade.pair) if self.edge else self.strategy.stoploss
stop_price = trade.open_rate * (1 + stoploss)
if self.create_stoploss_order(trade=trade, stop_price=stop_price, rate=stop_price):
if self.create_stoploss_order(trade=trade, stop_price=stop_price):
trade.stoploss_last_update = datetime.now()
return False
# If stoploss order is canceled for some reason we add it
if stoploss_order and stoploss_order['status'] in ('canceled', 'cancelled'):
if self.create_stoploss_order(trade=trade, stop_price=trade.stop_loss,
rate=trade.stop_loss):
if self.create_stoploss_order(trade=trade, stop_price=trade.stop_loss):
return False
else:
trade.stoploss_order_id = None
@@ -877,8 +876,7 @@ class FreqtradeBot:
f"for pair {trade.pair}")
# Create new stoploss order
if not self.create_stoploss_order(trade=trade, stop_price=trade.stop_loss,
rate=trade.stop_loss):
if not self.create_stoploss_order(trade=trade, stop_price=trade.stop_loss):
logger.warning(f"Could not create trailing stoploss order "
f"for pair {trade.pair}.")
@@ -923,7 +921,7 @@ class FreqtradeBot:
if not trade.open_order_id:
continue
order = self.exchange.fetch_order(trade.open_order_id, trade.pair)
except (ExchangeError, InvalidOrderException):
except (ExchangeError):
logger.info('Cannot query order for %s due to %s', trade, traceback.format_exc())
continue
@@ -956,7 +954,7 @@ class FreqtradeBot:
for trade in Trade.get_open_order_trades():
try:
order = self.exchange.fetch_order(trade.open_order_id, trade.pair)
except (DependencyException, InvalidOrderException):
except (ExchangeError):
logger.info('Cannot query order for %s due to %s', trade, traceback.format_exc())
continue