Fix calculation issue for #9346

Closes #9346
This commit is contained in:
Matthias 2023-10-29 14:29:07 +01:00
parent 24dfd9b93b
commit 0c51e2637f
2 changed files with 2 additions and 3 deletions

View File

@ -1053,7 +1053,7 @@ class LocalTrade:
price = avg_price if is_exit else tmp_price
current_stake += price * tmp_amount * side
if current_amount > ZERO:
if current_amount > ZERO and not is_exit:
avg_price = current_stake / current_amount
if is_exit:

View File

@ -2392,9 +2392,8 @@ def test_recalc_trade_from_orders_kucoin():
trade.update_trade(order3)
# assert trade.amount == o1_amount + o2_amount
assert trade.is_open is False
# The below values are wrong.
assert trade.amount == 8e-09
assert trade.close_profit_abs == -8270.49735089
assert trade.close_profit_abs == 3.90069871
@pytest.mark.parametrize('is_short', [True, False])