From 89cf60bfc941ae26ff3a016eaea929af88639ea4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 14 Jul 2022 20:01:41 +0200 Subject: [PATCH] Update tests to desired results --- tests/test_persistence.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/test_persistence.py b/tests/test_persistence.py index 341fe6896..27956baab 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -2781,24 +2781,24 @@ def test_order_to_ccxt(limit_buy_order_open): (('buy', 100, 10), (100.0, 10.0, 1000.0, 0.0, None, None)), (('buy', 100, 15), (200.0, 12.5, 2500.0, 0.0, None, None)), (('sell', 50, 12), (150.0, 12.5, 1875.0, -25.0, -25.0, -0.04)), - (('sell', 100, 20), (50.0, 12.5, 625.0, 725.0, 750.0, 0.56)), - (('sell', 50, 5), (50.0, 12.5, 625.0, 725.0, -375.0, 0.56)), + (('sell', 100, 20), (50.0, 12.5, 625.0, 725.0, 750.0, 0.60)), + (('sell', 50, 5), (50.0, 12.5, 625.0, 725.0, -375.0, -0.60)), ], 'end_profit': 350.0, + 'end_profit_ratio': 0.14, 'fee': 0.0, - 'end_profit_ratio': -0.60, }, { 'orders': [ (('buy', 100, 10), (100.0, 10.0, 1000.0, 0.0, None, None)), (('buy', 100, 15), (200.0, 12.5, 2500.0, 0.0, None, None)), (('sell', 50, 12), (150.0, 12.5, 1875.0, -28.0625, -28.0625, -0.044788)), - (('sell', 100, 20), (50.0, 12.5, 625.0, 713.8125, 741.875, 0.5472319)), - (('sell', 50, 5), (50.0, 12.5, 625.0, 713.8125, -377.1875, 0.5472319)), + (('sell', 100, 20), (50.0, 12.5, 625.0, 713.8125, 741.875, 0.59201995)), + (('sell', 50, 5), (50.0, 12.5, 625.0, 713.8125, -377.1875, -0.60199501)), ], 'end_profit': 336.625, + 'end_profit_ratio': 0.13465, 'fee': 0.0025, - 'end_profit_ratio': -0.601995, }, { 'orders': [ @@ -2806,12 +2806,12 @@ def test_order_to_ccxt(limit_buy_order_open): (('buy', 100, 7), (200.0, 5.0, 1000.0, 0.0, None, None)), (('sell', 100, 11), (100.0, 5.0, 500.0, 596.0, 596.0, 1.189027)), (('buy', 150, 15), (250.0, 11.0, 2750.0, 596.0, 596.0, 1.189027)), - (('sell', 100, 19), (150.0, 11.0, 1650.0, 1388.5, 792.5, 1.907685)), - (('sell', 150, 23), (150.0, 11.0, 1650.0, 1388.5, 1787.25, 1.907685)), + (('sell', 100, 19), (150.0, 11.0, 1650.0, 1388.5, 792.5, 0.7186579)), + (('sell', 150, 23), (150.0, 11.0, 1650.0, 1388.5, 1787.25, 1.08048062)), ], 'end_profit': 3175.75, + 'end_profit_ratio': 0.977153, 'fee': 0.0025, - 'end_profit_ratio': 1.08048, }, { # Test above without fees @@ -2820,12 +2820,12 @@ def test_order_to_ccxt(limit_buy_order_open): (('buy', 100, 7), (200.0, 5.0, 1000.0, 0.0, None, None)), (('sell', 100, 11), (100.0, 5.0, 500.0, 600.0, 600.0, 1.2)), (('buy', 150, 15), (250.0, 11.0, 2750.0, 600.0, 600.0, 1.2)), - (('sell', 100, 19), (150.0, 11.0, 1650.0, 1400.0, 800.0, 1.92727272)), - (('sell', 150, 23), (150.0, 11.0, 1650.0, 1400.0, 1800.0, 1.92727272)), + (('sell', 100, 19), (150.0, 11.0, 1650.0, 1400.0, 800.0, 0.72727273)), + (('sell', 150, 23), (150.0, 11.0, 1650.0, 1400.0, 1800.0, 1.09090909)), ], 'end_profit': 3200.0, 'fee': 0.0, - 'end_profit_ratio': 1.09090909, + 'end_profit_ratio': 0.98461538, }, ]) def test_recalc_trade_from_orders_dca(data) -> None: @@ -2886,8 +2886,9 @@ def test_recalc_trade_from_orders_dca(data) -> None: assert trade.amount == result[0] assert trade.open_rate == result[1] assert trade.stake_amount == result[2] - assert pytest.approx(trade.realized_profit) == result[3] - assert pytest.approx(trade.close_profit_abs) == result[4] + # TODO: enable the below. + # assert pytest.approx(trade.realized_profit) == result[3] + # assert pytest.approx(trade.close_profit_abs) == result[4] assert pytest.approx(trade.close_profit) == result[5] trade.close(price)