mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 20:23:57 +00:00
fix ruff format
This commit is contained in:
parent
0d3ab37eb7
commit
c6d7ae9d27
|
@ -720,7 +720,8 @@ class FreqtradeBot(LoggingMixin):
|
||||||
self.check_and_call_adjust_trade_position(trade)
|
self.check_and_call_adjust_trade_position(trade)
|
||||||
except DependencyException as exception:
|
except DependencyException as exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Unable to adjust position of trade for {trade.pair}: {exception}")
|
f"Unable to adjust position of trade for {trade.pair}: {exception}"
|
||||||
|
)
|
||||||
|
|
||||||
def check_and_call_adjust_trade_position(self, trade: Trade):
|
def check_and_call_adjust_trade_position(self, trade: Trade):
|
||||||
"""
|
"""
|
||||||
|
@ -1245,10 +1246,7 @@ class FreqtradeBot(LoggingMixin):
|
||||||
"""
|
"""
|
||||||
trades_closed = 0
|
trades_closed = 0
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
if (
|
if not trade.has_open_sl_orders and not self.wallets.check_exit_amount(trade):
|
||||||
not trade.has_open_sl_orders
|
|
||||||
and not self.wallets.check_exit_amount(trade)
|
|
||||||
):
|
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Not enough {trade.safe_base_currency} in wallet to exit {trade}. "
|
f"Not enough {trade.safe_base_currency} in wallet to exit {trade}. "
|
||||||
"Trying to recover."
|
"Trying to recover."
|
||||||
|
@ -1700,16 +1698,12 @@ class FreqtradeBot(LoggingMixin):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for side in sides:
|
for side in sides:
|
||||||
if (order["side"] == side):
|
if order["side"] == side:
|
||||||
if order["side"] == trade.entry_side:
|
if order["side"] == trade.entry_side:
|
||||||
self.handle_cancel_enter(
|
self.handle_cancel_enter(trade, order, open_order, reason)
|
||||||
trade, order, open_order, reason
|
|
||||||
)
|
|
||||||
|
|
||||||
elif order["side"] == trade.exit_side:
|
elif order["side"] == trade.exit_side:
|
||||||
self.handle_cancel_exit(
|
self.handle_cancel_exit(trade, order, open_order, reason)
|
||||||
trade, order, open_order, reason
|
|
||||||
)
|
|
||||||
|
|
||||||
def cancel_all_open_orders(self) -> None:
|
def cancel_all_open_orders(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -1719,8 +1713,7 @@ class FreqtradeBot(LoggingMixin):
|
||||||
|
|
||||||
for trade in Trade.get_open_trades():
|
for trade in Trade.get_open_trades():
|
||||||
self.cancel_open_orders_of_trade(
|
self.cancel_open_orders_of_trade(
|
||||||
trade, constants.CANCEL_REASON["ALL_CANCELLED"],
|
trade, constants.CANCEL_REASON["ALL_CANCELLED"], [trade.entry_side, trade.exit_side]
|
||||||
[trade.entry_side, trade.exit_side]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Trade.commit()
|
Trade.commit()
|
||||||
|
@ -1971,8 +1964,7 @@ class FreqtradeBot(LoggingMixin):
|
||||||
if trade.has_open_orders:
|
if trade.has_open_orders:
|
||||||
# cancel any open order of this trade
|
# cancel any open order of this trade
|
||||||
self.cancel_open_orders_of_trade(
|
self.cancel_open_orders_of_trade(
|
||||||
trade, constants.CANCEL_REASON["REPLACE"],
|
trade, constants.CANCEL_REASON["REPLACE"], [trade.exit_side]
|
||||||
[trade.exit_side]
|
|
||||||
)
|
)
|
||||||
Trade.commit()
|
Trade.commit()
|
||||||
|
|
||||||
|
|
|
@ -592,8 +592,7 @@ class LocalTrade:
|
||||||
True if there are open entry orders for this trade
|
True if there are open entry orders for this trade
|
||||||
"""
|
"""
|
||||||
open_entry_orders = [
|
open_entry_orders = [
|
||||||
o for o in self.orders
|
o for o in self.orders if o.ft_order_side == self.entry_side and o.ft_is_open
|
||||||
if o.ft_order_side == self.entry_side and o.ft_is_open
|
|
||||||
]
|
]
|
||||||
return len(open_entry_orders) > 0
|
return len(open_entry_orders) > 0
|
||||||
|
|
||||||
|
@ -602,32 +601,20 @@ class LocalTrade:
|
||||||
"""
|
"""
|
||||||
True if there is an open position for this trade
|
True if there is an open position for this trade
|
||||||
"""
|
"""
|
||||||
entry_orders = [
|
entry_orders = [o for o in self.orders if o.ft_order_side == self.entry_side]
|
||||||
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)
|
entry_orders_filled_qty = sum(eno.safe_filled for eno in entry_orders)
|
||||||
|
|
||||||
exit_orders = [
|
exit_orders = [o for o in self.orders if o.ft_order_side == self.exit_side]
|
||||||
o for o in self.orders
|
|
||||||
if o.ft_order_side == self.exit_side
|
|
||||||
]
|
|
||||||
exit_orders_filled_qty = sum(exo.safe_filled for exo in exit_orders)
|
exit_orders_filled_qty = sum(exo.safe_filled for exo in exit_orders)
|
||||||
|
|
||||||
return (entry_orders_filled_qty - exit_orders_filled_qty) > 0
|
return (entry_orders_filled_qty - exit_orders_filled_qty) > 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def untied_assets(self) -> float:
|
def untied_assets(self) -> float:
|
||||||
entry_orders = [
|
entry_orders = [o for o in self.orders if o.ft_order_side == self.entry_side]
|
||||||
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)
|
entry_orders_filled_qty = sum(eno.safe_filled for eno in entry_orders)
|
||||||
|
|
||||||
exit_orders = [
|
exit_orders = [o for o in self.orders if o.ft_order_side == self.exit_side]
|
||||||
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)
|
exit_orders_remaining_qty = sum(exo.safe_remaining for exo in exit_orders)
|
||||||
untied_remaining = entry_orders_filled_qty - exit_orders_remaining_qty
|
untied_remaining = entry_orders_filled_qty - exit_orders_remaining_qty
|
||||||
|
|
||||||
|
|
|
@ -1305,7 +1305,7 @@ def test_exit_positions_exception(mocker, default_conf_usdt, limit_order, caplog
|
||||||
ft_price=trade.open_rate,
|
ft_price=trade.open_rate,
|
||||||
order_id=order_id,
|
order_id=order_id,
|
||||||
ft_is_open=False,
|
ft_is_open=False,
|
||||||
filled=11
|
filled=11,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
Trade.session.add(trade)
|
Trade.session.add(trade)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user