Fix bug in exit-count detection
This commit is contained in:
parent
b419d0043c
commit
1c0946833d
@ -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,7 +706,6 @@ 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()
|
||||
|
||||
@ -715,7 +714,6 @@ class LocalTrade():
|
||||
: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:
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user