mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
add has_untied_assets, replace one has_open_orders condition by has_untied_assets in exit_positions
This commit is contained in:
parent
faeda2a166
commit
6752c3e288
|
@ -1093,7 +1093,7 @@ class FreqtradeBot(LoggingMixin):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f'Unable to handle stoploss on exchange for {trade.pair}: {exception}')
|
f'Unable to handle stoploss on exchange for {trade.pair}: {exception}')
|
||||||
# Check if we can sell our current pair
|
# Check if we can sell our current pair
|
||||||
if not trade.has_open_orders and trade.is_open and self.handle_trade(trade):
|
if trade.has_untied_assets and trade.is_open and self.handle_trade(trade):
|
||||||
trades_closed += 1
|
trades_closed += 1
|
||||||
|
|
||||||
except DependencyException as exception:
|
except DependencyException as exception:
|
||||||
|
|
|
@ -563,6 +563,26 @@ class LocalTrade:
|
||||||
|
|
||||||
return (entry_orders_filled_qty - exit_orders_filled_qty) > 0
|
return (entry_orders_filled_qty - exit_orders_filled_qty) > 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_untied_assets(self) -> bool:
|
||||||
|
"""
|
||||||
|
True if there is still remaining position not yet tied up to exit order
|
||||||
|
"""
|
||||||
|
entry_orders = [
|
||||||
|
o for o in self.orders
|
||||||
|
if o.ft_order_side == self.entry_side
|
||||||
|
]
|
||||||
|
entry_orders_filled_qty = sum(eno.safe_filled for eno in entry_orders)
|
||||||
|
|
||||||
|
exit_orders = [
|
||||||
|
o for o in self.orders
|
||||||
|
if o.ft_order_side == self.exit_side
|
||||||
|
]
|
||||||
|
exit_orders_remaining_qty = sum(exo.safe_remaining for exo in exit_orders)
|
||||||
|
untied_remaining = entry_orders_filled_qty - exit_orders_remaining_qty
|
||||||
|
|
||||||
|
return untied_remaining > 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def open_sl_orders(self) -> List[Order]:
|
def open_sl_orders(self) -> List[Order]:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user