Skip to content

Commit cf563c1

Browse files
committed
test: update tests for new best-pair logic
1 parent 99b2857 commit cf563c1

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

tests/persistence/test_persistence.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,9 +1931,9 @@ def test_get_overall_performance(fee):
19311931
@pytest.mark.parametrize(
19321932
"is_short,pair,profit",
19331933
[
1934-
(True, "ETC/BTC", -0.005),
1935-
(False, "XRP/BTC", 0.01),
1936-
(None, "XRP/BTC", 0.01),
1934+
(True, "XRP/BTC", -0.00018780487),
1935+
(False, "ETC/BTC", 0.00003860975),
1936+
(None, "XRP/BTC", 0.000025203252),
19371937
],
19381938
)
19391939
def test_get_best_pair(fee, is_short, pair, profit):
@@ -1942,9 +1942,9 @@ def test_get_best_pair(fee, is_short, pair, profit):
19421942

19431943
create_mock_trades(fee, is_short)
19441944
res = Trade.get_best_pair()
1945-
assert len(res) == 2
1945+
assert len(res) == 4
19461946
assert res[0] == pair
1947-
assert res[1] == profit
1947+
assert pytest.approx(res[1]) == profit
19481948

19491949

19501950
@pytest.mark.usefixtures("init_persistence")
@@ -1954,9 +1954,9 @@ def test_get_best_pair_lev(fee):
19541954

19551955
create_mock_trades_with_leverage(fee)
19561956
res = Trade.get_best_pair()
1957-
assert len(res) == 2
1958-
assert res[0] == "DOGE/BTC"
1959-
assert res[1] == 0.1713156134055116
1957+
assert len(res) == 4
1958+
assert res[0] == "ETC/BTC"
1959+
assert pytest.approx(res[1]) == 0.00003860975
19601960

19611961

19621962
@pytest.mark.usefixtures("init_persistence")

tests/rpc/test_rpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ def test_rpc_trade_statistics(default_conf_usdt, ticker, fee, mocker) -> None:
480480
assert stats["first_trade_humanized"] == "2 days ago"
481481
assert stats["latest_trade_humanized"] == "17 minutes ago"
482482
assert stats["avg_duration"] in ("0:17:40")
483-
assert stats["best_pair"] == "XRP/USDT"
484-
assert stats["best_rate"] == 10.0
483+
assert stats["best_pair"] == "NEO/USDT"
484+
assert stats["best_rate"] == 1.99
485485

486486
# Test non-available pair
487487
mocker.patch(
@@ -492,8 +492,8 @@ def test_rpc_trade_statistics(default_conf_usdt, ticker, fee, mocker) -> None:
492492
assert stats["first_trade_humanized"] == "2 days ago"
493493
assert stats["latest_trade_humanized"] == "17 minutes ago"
494494
assert stats["avg_duration"] in ("0:17:40")
495-
assert stats["best_pair"] == "XRP/USDT"
496-
assert stats["best_rate"] == 10.0
495+
assert stats["best_pair"] == "NEO/USDT"
496+
assert stats["best_rate"] == 1.99
497497
assert isnan(stats["profit_all_coin"])
498498

499499

tests/rpc/test_rpc_apiserver.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -963,9 +963,10 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
963963
(
964964
True,
965965
{
966-
"best_pair": "ETC/BTC",
967-
"best_rate": -0.5,
968-
"best_pair_profit_ratio": -0.005,
966+
"best_pair": "XRP/BTC",
967+
"best_rate": -0.02,
968+
"best_pair_profit_ratio": -0.00018780487,
969+
"best_pair_profit_abs": -0.001155,
969970
"profit_all_coin": 15.382312,
970971
"profit_all_fiat": 189894.6470718,
971972
"profit_all_percent_mean": 49.62,
@@ -994,9 +995,10 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
994995
(
995996
False,
996997
{
997-
"best_pair": "XRP/BTC",
998-
"best_rate": 1.0,
999-
"best_pair_profit_ratio": 0.01,
998+
"best_pair": "ETC/BTC",
999+
"best_rate": 0.0,
1000+
"best_pair_profit_ratio": 0.00003860975,
1001+
"best_pair_profit_abs": 0.000584127,
10001002
"profit_all_coin": -15.46546305,
10011003
"profit_all_fiat": -190921.14135225,
10021004
"profit_all_percent_mean": -49.62,
@@ -1026,8 +1028,9 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
10261028
None,
10271029
{
10281030
"best_pair": "XRP/BTC",
1029-
"best_rate": 1.0,
1030-
"best_pair_profit_ratio": 0.01,
1031+
"best_rate": 0.0,
1032+
"best_pair_profit_ratio": 0.000025203252,
1033+
"best_pair_profit_abs": 0.000155,
10311034
"profit_all_coin": -14.87167525,
10321035
"profit_all_fiat": -183590.83096125,
10331036
"profit_all_percent_mean": 0.13,
@@ -1080,7 +1083,8 @@ def test_api_profit(botclient, mocker, ticker, fee, markets, is_short, expected)
10801083
assert rc.json() == {
10811084
"avg_duration": ANY,
10821085
"best_pair": expected["best_pair"],
1083-
"best_pair_profit_ratio": expected["best_pair_profit_ratio"],
1086+
"best_pair_profit_ratio": pytest.approx(expected["best_pair_profit_ratio"]),
1087+
"best_pair_profit_abs": expected["best_pair_profit_abs"],
10841088
"best_rate": expected["best_rate"],
10851089
"first_trade_date": ANY,
10861090
"first_trade_humanized": ANY,

tests/rpc/test_rpc_telegram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ async def test_telegram_profit_handle(
918918
)
919919
assert "∙ `6.253 USD`" in msg_mock.call_args_list[-1][0][0]
920920

921-
assert "*Best Performing:* `ETH/USDT: 9.45%`" in msg_mock.call_args_list[-1][0][0]
921+
assert "*Best Performing:* `ETH/USDT: 5.685 USDT (9.47%)`" in msg_mock.call_args_list[-1][0][0]
922922
assert "*Max Drawdown:*" in msg_mock.call_args_list[-1][0][0]
923923
assert "*Profit factor:*" in msg_mock.call_args_list[-1][0][0]
924924
assert "*Winrate:*" in msg_mock.call_args_list[-1][0][0]

0 commit comments

Comments
 (0)