Fix and improve process_maybe_execute_sells()
This commit is contained in:
parent
15aae8a58c
commit
89729aefe8
@ -446,25 +446,26 @@ class FreqtradeBot:
|
|||||||
"""
|
"""
|
||||||
Tries to execute sell trades in a safe way
|
Tries to execute sell trades in a safe way
|
||||||
"""
|
"""
|
||||||
|
result = False
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
try:
|
try:
|
||||||
self.update_trade_state(trade)
|
self.update_trade_state(trade)
|
||||||
|
|
||||||
if trade.is_open:
|
if (self.strategy.order_types.get('stoploss_on_exchange') and
|
||||||
result = False
|
self.handle_stoploss_on_exchange(trade)):
|
||||||
if self.strategy.order_types.get('stoploss_on_exchange'):
|
result = True
|
||||||
result = self.handle_stoploss_on_exchange(trade)
|
continue
|
||||||
elif trade.open_order_id is None:
|
# Check if we can sell our current pair
|
||||||
# Check if we can sell our current pair
|
if trade.open_order_id is None and self.handle_trade(trade):
|
||||||
result = self.handle_trade(trade)
|
result = True
|
||||||
|
|
||||||
# Updating wallets if any trade occured
|
|
||||||
if result:
|
|
||||||
self.wallets.update()
|
|
||||||
|
|
||||||
except DependencyException as exception:
|
except DependencyException as exception:
|
||||||
logger.warning('Unable to sell trade: %s', exception)
|
logger.warning('Unable to sell trade: %s', exception)
|
||||||
|
|
||||||
|
# Updating wallets if any trade occured
|
||||||
|
if result:
|
||||||
|
self.wallets.update()
|
||||||
|
|
||||||
def get_real_amount(self, trade: Trade, order: Dict) -> float:
|
def get_real_amount(self, trade: Trade, order: Dict) -> float:
|
||||||
"""
|
"""
|
||||||
Get real amount for the trade
|
Get real amount for the trade
|
||||||
@ -569,7 +570,7 @@ class FreqtradeBot:
|
|||||||
:return: True if trade has been sold, False otherwise
|
:return: True if trade has been sold, False otherwise
|
||||||
"""
|
"""
|
||||||
if not trade.is_open:
|
if not trade.is_open:
|
||||||
raise ValueError(f'Attempt to handle closed trade: {trade}')
|
raise DependencyException(f'Attempt to handle closed trade: {trade}')
|
||||||
|
|
||||||
logger.debug('Handling %s ...', trade)
|
logger.debug('Handling %s ...', trade)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user