From c6d7ae9d27fe06e35ec57800b2f1e7b28898b1e1 Mon Sep 17 00:00:00 2001 From: Axel-CH Date: Fri, 20 Sep 2024 19:10:52 -0400 Subject: [PATCH] fix ruff format --- freqtrade/freqtradebot.py | 24 ++++++++---------------- freqtrade/persistence/trade_model.py | 23 +++++------------------ tests/freqtradebot/test_freqtradebot.py | 2 +- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index dd39eb395..fbad3596f 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -720,7 +720,8 @@ class FreqtradeBot(LoggingMixin): self.check_and_call_adjust_trade_position(trade) except DependencyException as exception: 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): """ @@ -1245,10 +1246,7 @@ class FreqtradeBot(LoggingMixin): """ trades_closed = 0 for trade in trades: - if ( - not trade.has_open_sl_orders - and not self.wallets.check_exit_amount(trade) - ): + if not trade.has_open_sl_orders and not self.wallets.check_exit_amount(trade): logger.warning( f"Not enough {trade.safe_base_currency} in wallet to exit {trade}. " "Trying to recover." @@ -1700,16 +1698,12 @@ class FreqtradeBot(LoggingMixin): continue for side in sides: - if (order["side"] == side): + if order["side"] == side: if order["side"] == trade.entry_side: - self.handle_cancel_enter( - trade, order, open_order, reason - ) + self.handle_cancel_enter(trade, order, open_order, reason) elif order["side"] == trade.exit_side: - self.handle_cancel_exit( - trade, order, open_order, reason - ) + self.handle_cancel_exit(trade, order, open_order, reason) def cancel_all_open_orders(self) -> None: """ @@ -1719,8 +1713,7 @@ class FreqtradeBot(LoggingMixin): for trade in Trade.get_open_trades(): self.cancel_open_orders_of_trade( - trade, constants.CANCEL_REASON["ALL_CANCELLED"], - [trade.entry_side, trade.exit_side] + trade, constants.CANCEL_REASON["ALL_CANCELLED"], [trade.entry_side, trade.exit_side] ) Trade.commit() @@ -1971,8 +1964,7 @@ class FreqtradeBot(LoggingMixin): if trade.has_open_orders: # cancel any open order of this trade self.cancel_open_orders_of_trade( - trade, constants.CANCEL_REASON["REPLACE"], - [trade.exit_side] + trade, constants.CANCEL_REASON["REPLACE"], [trade.exit_side] ) Trade.commit() diff --git a/freqtrade/persistence/trade_model.py b/freqtrade/persistence/trade_model.py index 2746806c5..da3d1e570 100644 --- a/freqtrade/persistence/trade_model.py +++ b/freqtrade/persistence/trade_model.py @@ -592,8 +592,7 @@ class LocalTrade: True if there are open entry orders for this trade """ open_entry_orders = [ - o for o in self.orders - if o.ft_order_side == self.entry_side and o.ft_is_open + o for o in self.orders if o.ft_order_side == self.entry_side and o.ft_is_open ] return len(open_entry_orders) > 0 @@ -602,32 +601,20 @@ class LocalTrade: """ True if there is an open position for this trade """ - entry_orders = [ - o for o in self.orders - if o.ft_order_side == self.entry_side - ] + 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 = [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) return (entry_orders_filled_qty - exit_orders_filled_qty) > 0 @property def untied_assets(self) -> float: - entry_orders = [ - o for o in self.orders - if o.ft_order_side == self.entry_side - ] + 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 = [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 diff --git a/tests/freqtradebot/test_freqtradebot.py b/tests/freqtradebot/test_freqtradebot.py index ec934fe53..2ef03ed88 100644 --- a/tests/freqtradebot/test_freqtradebot.py +++ b/tests/freqtradebot/test_freqtradebot.py @@ -1305,7 +1305,7 @@ def test_exit_positions_exception(mocker, default_conf_usdt, limit_order, caplog ft_price=trade.open_rate, order_id=order_id, ft_is_open=False, - filled=11 + filled=11, ) ) Trade.session.add(trade)