From 119d4d5204534ba25b0d2d10510f4f21f04094ee Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 12 Feb 2022 17:06:03 +0100 Subject: [PATCH] select_order should use ft_order_side, not the exchange specific one --- freqtrade/persistence/models.py | 4 ++-- tests/test_persistence.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index dfa98d97f..5f2db1050 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -659,13 +659,13 @@ class LocalTrade(): self, order_side: str = None, is_open: Optional[bool] = None) -> Optional[Order]: """ Finds latest order for this orderside and status - :param order_side: Side of the order (either 'buy' or 'sell') + :param order_side: ft_order_side of the order (either 'buy', 'sell' or 'stoploss') :param is_open: Only search for open orders? :return: latest Order object if it exists, else None """ orders = self.orders if order_side: - orders = [o for o in self.orders if o.side == order_side] + orders = [o for o in self.orders if o.ft_order_side == order_side] if is_open is not None: orders = [o for o in orders if o.ft_is_open == is_open] if len(orders) > 0: diff --git a/tests/test_persistence.py b/tests/test_persistence.py index 97851fdc4..b8f7a3336 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -1277,11 +1277,14 @@ def test_select_order(fee): order = trades[4].select_order('buy', False) assert order is not None + trades[4].orders[1].ft_order_side = 'sell' order = trades[4].select_order('sell', True) assert order is not None + + trades[4].orders[1].ft_order_side = 'stoploss' + order = trades[4].select_order('stoploss', None) + assert order is not None assert order.ft_order_side == 'stoploss' - order = trades[4].select_order('sell', False) - assert order is None def test_Trade_object_idem():