diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index e4559d1f6..f5dd5f1f2 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -688,7 +688,7 @@ class LocalTrade(): Get amount of failed exiting orders assumes full exits. """ - return len([o for o in self.orders if o.ft_order_side == 'sell']) + return len([o for o in self.orders if o.ft_order_side == self.exit_side]) def _calc_open_trade_value(self) -> float: """ @@ -706,16 +706,14 @@ class LocalTrade(): """ Recalculate open_trade_value. Must be called whenever open_rate, fee_open or is_short is changed. - """ self.open_trade_value = self._calc_open_trade_value() def calculate_interest(self, interest_rate: Optional[float] = None) -> Decimal: """ - : param interest_rate: interest_charge for borrowing this coin(optional). + :param interest_rate: interest_charge for borrowing this coin(optional). If interest_rate is not set self.interest_rate will be used """ - zero = Decimal(0.0) # If nothing was borrowed if self.trading_mode != TradingMode.MARGIN or self.has_no_leverage: diff --git a/tests/test_persistence.py b/tests/test_persistence.py index 207a37313..34fc98fef 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -2057,10 +2057,11 @@ def test_get_best_pair_lev(fee): @pytest.mark.usefixtures("init_persistence") -def test_get_exit_order_count(fee): +@pytest.mark.parametrize('is_short', [True, False]) +def test_get_exit_order_count(fee, is_short): - create_mock_trades_usdt(fee) - trade = Trade.get_trades([Trade.pair == 'ETC/USDT']).first() + create_mock_trades(fee, is_short=is_short) + trade = Trade.get_trades([Trade.pair == 'ETC/BTC']).first() assert trade.get_exit_order_count() == 1