Merge branch 'develop' into feat/binance_trades_fast
This commit is contained in:
@@ -1931,9 +1931,9 @@ def test_get_overall_performance(fee):
|
||||
@pytest.mark.parametrize(
|
||||
"is_short,pair,profit",
|
||||
[
|
||||
(True, "ETC/BTC", -0.005),
|
||||
(False, "XRP/BTC", 0.01),
|
||||
(None, "XRP/BTC", 0.01),
|
||||
(True, "XRP/BTC", -0.00018780487),
|
||||
(False, "ETC/BTC", 0.00003860975),
|
||||
(None, "XRP/BTC", 0.000025203252),
|
||||
],
|
||||
)
|
||||
def test_get_best_pair(fee, is_short, pair, profit):
|
||||
@@ -1942,9 +1942,9 @@ def test_get_best_pair(fee, is_short, pair, profit):
|
||||
|
||||
create_mock_trades(fee, is_short)
|
||||
res = Trade.get_best_pair()
|
||||
assert len(res) == 2
|
||||
assert len(res) == 4
|
||||
assert res[0] == pair
|
||||
assert res[1] == profit
|
||||
assert pytest.approx(res[1]) == profit
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
@@ -1954,9 +1954,9 @@ def test_get_best_pair_lev(fee):
|
||||
|
||||
create_mock_trades_with_leverage(fee)
|
||||
res = Trade.get_best_pair()
|
||||
assert len(res) == 2
|
||||
assert res[0] == "DOGE/BTC"
|
||||
assert res[1] == 0.1713156134055116
|
||||
assert len(res) == 4
|
||||
assert res[0] == "ETC/BTC"
|
||||
assert pytest.approx(res[1]) == 0.00003860975
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
|
||||
+19
-13
@@ -480,8 +480,8 @@ def test_rpc_trade_statistics(default_conf_usdt, ticker, fee, mocker) -> None:
|
||||
assert stats["first_trade_humanized"] == "2 days ago"
|
||||
assert stats["latest_trade_humanized"] == "17 minutes ago"
|
||||
assert stats["avg_duration"] in ("0:17:40")
|
||||
assert stats["best_pair"] == "XRP/USDT"
|
||||
assert stats["best_rate"] == 10.0
|
||||
assert stats["best_pair"] == "NEO/USDT"
|
||||
assert stats["best_rate"] == 1.99
|
||||
|
||||
# Test non-available pair
|
||||
mocker.patch(
|
||||
@@ -492,8 +492,8 @@ def test_rpc_trade_statistics(default_conf_usdt, ticker, fee, mocker) -> None:
|
||||
assert stats["first_trade_humanized"] == "2 days ago"
|
||||
assert stats["latest_trade_humanized"] == "17 minutes ago"
|
||||
assert stats["avg_duration"] in ("0:17:40")
|
||||
assert stats["best_pair"] == "XRP/USDT"
|
||||
assert stats["best_rate"] == 10.0
|
||||
assert stats["best_pair"] == "NEO/USDT"
|
||||
assert stats["best_rate"] == 1.99
|
||||
assert isnan(stats["profit_all_coin"])
|
||||
|
||||
|
||||
@@ -1018,14 +1018,14 @@ def test_enter_tag_performance_handle(default_conf, ticker, fee, mocker) -> None
|
||||
assert len(res) == 3
|
||||
assert res[0]["enter_tag"] == "TEST1"
|
||||
assert res[0]["count"] == 1
|
||||
assert res[0]["profit_pct"] == 5.0
|
||||
assert res[0]["profit_pct"] == 1.99
|
||||
|
||||
res = rpc._rpc_enter_tag_performance(None)
|
||||
|
||||
assert len(res) == 3
|
||||
assert res[0]["enter_tag"] == "TEST1"
|
||||
assert res[0]["count"] == 1
|
||||
assert res[0]["profit_pct"] == 5.0
|
||||
assert res[0]["profit_pct"] == 1.99
|
||||
|
||||
|
||||
def test_enter_tag_performance_handle_2(mocker, default_conf, markets, fee):
|
||||
@@ -1041,17 +1041,20 @@ def test_enter_tag_performance_handle_2(mocker, default_conf, markets, fee):
|
||||
assert len(res) == 2
|
||||
assert res[0]["enter_tag"] == "TEST1"
|
||||
assert res[0]["count"] == 1
|
||||
assert pytest.approx(res[0]["profit_pct"]) == 0.5
|
||||
assert pytest.approx(res[0]["profit_pct"]) == 0.0
|
||||
assert pytest.approx(res[0]["profit_ratio"]) == 0.00003860975
|
||||
assert res[1]["enter_tag"] == "Other"
|
||||
assert res[1]["count"] == 1
|
||||
assert pytest.approx(res[1]["profit_pct"]) == 1.0
|
||||
assert pytest.approx(res[1]["profit_pct"]) == 0.0
|
||||
assert pytest.approx(res[1]["profit_ratio"]) == 0.00002520325
|
||||
|
||||
# Test for a specific pair
|
||||
res = rpc._rpc_enter_tag_performance("ETC/BTC")
|
||||
assert len(res) == 1
|
||||
assert res[0]["count"] == 1
|
||||
assert res[0]["enter_tag"] == "TEST1"
|
||||
assert pytest.approx(res[0]["profit_pct"]) == 0.5
|
||||
assert pytest.approx(res[0]["profit_pct"]) == 0.0
|
||||
assert pytest.approx(res[0]["profit_ratio"]) == 0.00003860975
|
||||
|
||||
|
||||
def test_exit_reason_performance_handle(default_conf_usdt, ticker, fee, mocker) -> None:
|
||||
@@ -1075,7 +1078,7 @@ def test_exit_reason_performance_handle(default_conf_usdt, ticker, fee, mocker)
|
||||
assert len(res) == 3
|
||||
assert res[0]["exit_reason"] == "exit_signal"
|
||||
assert res[0]["count"] == 1
|
||||
assert res[0]["profit_pct"] == 5.0
|
||||
assert res[0]["profit_pct"] == 1.99
|
||||
|
||||
assert res[1]["exit_reason"] == "roi"
|
||||
assert res[2]["exit_reason"] == "Other"
|
||||
@@ -1094,17 +1097,20 @@ def test_exit_reason_performance_handle_2(mocker, default_conf, markets, fee):
|
||||
assert len(res) == 2
|
||||
assert res[0]["exit_reason"] == "sell_signal"
|
||||
assert res[0]["count"] == 1
|
||||
assert pytest.approx(res[0]["profit_pct"]) == 0.5
|
||||
assert pytest.approx(res[0]["profit_pct"]) == 0.0
|
||||
assert pytest.approx(res[0]["profit_ratio"]) == 0.00003860975
|
||||
assert res[1]["exit_reason"] == "roi"
|
||||
assert res[1]["count"] == 1
|
||||
assert pytest.approx(res[1]["profit_pct"]) == 1.0
|
||||
assert pytest.approx(res[1]["profit_pct"]) == 0.0
|
||||
assert pytest.approx(res[1]["profit_ratio"]) == 0.000025203252
|
||||
|
||||
# Test for a specific pair
|
||||
res = rpc._rpc_exit_reason_performance("ETC/BTC")
|
||||
assert len(res) == 1
|
||||
assert res[0]["count"] == 1
|
||||
assert res[0]["exit_reason"] == "sell_signal"
|
||||
assert pytest.approx(res[0]["profit_pct"]) == 0.5
|
||||
assert pytest.approx(res[0]["profit_pct"]) == 0.0
|
||||
assert pytest.approx(res[0]["profit_ratio"]) == 0.00003860975
|
||||
|
||||
|
||||
def test_mix_tag_performance_handle(default_conf, ticker, fee, mocker) -> None:
|
||||
|
||||
@@ -963,9 +963,10 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
|
||||
(
|
||||
True,
|
||||
{
|
||||
"best_pair": "ETC/BTC",
|
||||
"best_rate": -0.5,
|
||||
"best_pair_profit_ratio": -0.005,
|
||||
"best_pair": "XRP/BTC",
|
||||
"best_rate": -0.02,
|
||||
"best_pair_profit_ratio": -0.00018780487,
|
||||
"best_pair_profit_abs": -0.001155,
|
||||
"profit_all_coin": 15.382312,
|
||||
"profit_all_fiat": 189894.6470718,
|
||||
"profit_all_percent_mean": 49.62,
|
||||
@@ -994,9 +995,10 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
|
||||
(
|
||||
False,
|
||||
{
|
||||
"best_pair": "XRP/BTC",
|
||||
"best_rate": 1.0,
|
||||
"best_pair_profit_ratio": 0.01,
|
||||
"best_pair": "ETC/BTC",
|
||||
"best_rate": 0.0,
|
||||
"best_pair_profit_ratio": 0.00003860975,
|
||||
"best_pair_profit_abs": 0.000584127,
|
||||
"profit_all_coin": -15.46546305,
|
||||
"profit_all_fiat": -190921.14135225,
|
||||
"profit_all_percent_mean": -49.62,
|
||||
@@ -1026,8 +1028,9 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
|
||||
None,
|
||||
{
|
||||
"best_pair": "XRP/BTC",
|
||||
"best_rate": 1.0,
|
||||
"best_pair_profit_ratio": 0.01,
|
||||
"best_rate": 0.0,
|
||||
"best_pair_profit_ratio": 0.000025203252,
|
||||
"best_pair_profit_abs": 0.000155,
|
||||
"profit_all_coin": -14.87167525,
|
||||
"profit_all_fiat": -183590.83096125,
|
||||
"profit_all_percent_mean": 0.13,
|
||||
@@ -1080,7 +1083,8 @@ def test_api_profit(botclient, mocker, ticker, fee, markets, is_short, expected)
|
||||
assert rc.json() == {
|
||||
"avg_duration": ANY,
|
||||
"best_pair": expected["best_pair"],
|
||||
"best_pair_profit_ratio": expected["best_pair_profit_ratio"],
|
||||
"best_pair_profit_ratio": pytest.approx(expected["best_pair_profit_ratio"]),
|
||||
"best_pair_profit_abs": expected["best_pair_profit_abs"],
|
||||
"best_rate": expected["best_rate"],
|
||||
"first_trade_date": ANY,
|
||||
"first_trade_humanized": ANY,
|
||||
@@ -1206,7 +1210,8 @@ def test_api_entries(botclient, fee):
|
||||
resp = response[0]
|
||||
assert resp["enter_tag"] == "TEST1"
|
||||
assert resp["count"] == 1
|
||||
assert resp["profit_pct"] == 0.5
|
||||
assert resp["profit_pct"] == 0.0
|
||||
assert pytest.approx(resp["profit_ratio"]) == 0.000038609756
|
||||
|
||||
|
||||
def test_api_exits(botclient, fee):
|
||||
@@ -1225,7 +1230,8 @@ def test_api_exits(botclient, fee):
|
||||
resp = response[0]
|
||||
assert resp["exit_reason"] == "sell_signal"
|
||||
assert resp["count"] == 1
|
||||
assert resp["profit_pct"] == 0.5
|
||||
assert resp["profit_pct"] == 0.0
|
||||
assert pytest.approx(resp["profit_ratio"]) == 0.000038609756
|
||||
|
||||
|
||||
def test_api_mix_tag(botclient, fee):
|
||||
|
||||
@@ -918,7 +918,7 @@ async def test_telegram_profit_handle(
|
||||
)
|
||||
assert "∙ `6.253 USD`" in msg_mock.call_args_list[-1][0][0]
|
||||
|
||||
assert "*Best Performing:* `ETH/USDT: 9.45%`" in msg_mock.call_args_list[-1][0][0]
|
||||
assert "*Best Performing:* `ETH/USDT: 5.685 USDT (9.47%)`" in msg_mock.call_args_list[-1][0][0]
|
||||
assert "*Max Drawdown:*" in msg_mock.call_args_list[-1][0][0]
|
||||
assert "*Profit factor:*" in msg_mock.call_args_list[-1][0][0]
|
||||
assert "*Winrate:*" in msg_mock.call_args_list[-1][0][0]
|
||||
@@ -1611,7 +1611,7 @@ async def test_telegram_entry_tag_performance_handle(
|
||||
await telegram._enter_tag_performance(update=update, context=context)
|
||||
assert msg_mock.call_count == 1
|
||||
assert "Entry Tag Performance" in msg_mock.call_args_list[0][0][0]
|
||||
assert "`TEST1\t3.987 USDT (5.00%) (1)`" in msg_mock.call_args_list[0][0][0]
|
||||
assert "`TEST1\t3.987 USDT (1.99%) (1)`" in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
context.args = ["XRP/USDT"]
|
||||
await telegram._enter_tag_performance(update=update, context=context)
|
||||
@@ -1644,7 +1644,7 @@ async def test_telegram_exit_reason_performance_handle(
|
||||
await telegram._exit_reason_performance(update=update, context=context)
|
||||
assert msg_mock.call_count == 1
|
||||
assert "Exit Reason Performance" in msg_mock.call_args_list[0][0][0]
|
||||
assert "`roi\t2.842 USDT (10.00%) (1)`" in msg_mock.call_args_list[0][0][0]
|
||||
assert "`roi\t2.842 USDT (9.47%) (1)`" in msg_mock.call_args_list[0][0][0]
|
||||
context.args = ["XRP/USDT"]
|
||||
|
||||
await telegram._exit_reason_performance(update=update, context=context)
|
||||
|
||||
Reference in New Issue
Block a user