mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 05:50:36 +00:00
test: adapt starting capital tests for tradable_balance_ratio
This commit is contained in:
@@ -680,8 +680,8 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers):
|
||||
]
|
||||
assert pytest.approx(result["total_bot"]) == 69.5
|
||||
assert pytest.approx(result["total"]) == 2824.83464 # ETH stake is missing.
|
||||
assert result["starting_capital"] == 50
|
||||
assert result["starting_capital_ratio"] == pytest.approx(0.3899999)
|
||||
assert result["starting_capital"] == 50 * default_conf_usdt["tradable_balance_ratio"]
|
||||
assert result["starting_capital_ratio"] == pytest.approx(0.4040404)
|
||||
|
||||
|
||||
def test_rpc_start(mocker, default_conf) -> None:
|
||||
|
||||
@@ -1056,6 +1056,7 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets):
|
||||
)
|
||||
def test_api_profit(botclient, mocker, ticker, fee, markets, is_short, expected):
|
||||
ftbot, client = botclient
|
||||
ftbot.config["tradable_balance_ratio"] = 1
|
||||
patch_get_signal(ftbot)
|
||||
mocker.patch.multiple(
|
||||
EXMS,
|
||||
|
||||
@@ -1087,7 +1087,7 @@ async def test_balance_handle_empty_response_dry(default_conf, update, mocker) -
|
||||
result = msg_mock.call_args_list[0][0][0]
|
||||
assert msg_mock.call_count == 1
|
||||
assert "*Warning:* Simulated balances in Dry Mode." in result
|
||||
assert "Starting capital: `1000 BTC`" in result
|
||||
assert "Starting capital: `990 BTC`" in result
|
||||
|
||||
|
||||
async def test_balance_handle_too_large_response(default_conf, update, mocker) -> None:
|
||||
|
||||
@@ -244,7 +244,7 @@ def test_get_starting_balance(
|
||||
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
|
||||
assert freqtrade.wallets.get_starting_balance() == expected
|
||||
assert freqtrade.wallets.get_starting_balance() == expected * (1 if available_capital else 0.99)
|
||||
|
||||
|
||||
def test_sync_wallet_futures_live(mocker, default_conf):
|
||||
@@ -373,7 +373,10 @@ def test_sync_wallet_dry(mocker, default_conf_usdt, fee):
|
||||
# sum of used and free should be total.
|
||||
assert usdt_bal.total == usdt_bal.free + usdt_bal.used
|
||||
|
||||
assert freqtrade.wallets.get_starting_balance() == default_conf_usdt["dry_run_wallet"]
|
||||
assert (
|
||||
freqtrade.wallets.get_starting_balance()
|
||||
== default_conf_usdt["dry_run_wallet"] * default_conf_usdt["tradable_balance_ratio"]
|
||||
)
|
||||
total = freqtrade.wallets.get_total("LTC")
|
||||
free = freqtrade.wallets.get_free("LTC")
|
||||
used = freqtrade.wallets.get_used("LTC")
|
||||
@@ -401,7 +404,10 @@ def test_sync_wallet_futures_dry(mocker, default_conf, fee):
|
||||
assert positions["XRP/BTC"].side == "long"
|
||||
assert positions["LTC/BTC"].side == "short"
|
||||
|
||||
assert freqtrade.wallets.get_starting_balance() == default_conf["dry_run_wallet"]
|
||||
assert (
|
||||
freqtrade.wallets.get_starting_balance()
|
||||
== default_conf["dry_run_wallet"] * default_conf["tradable_balance_ratio"]
|
||||
)
|
||||
total = freqtrade.wallets.get_total("BTC")
|
||||
free = freqtrade.wallets.get_free("BTC")
|
||||
used = freqtrade.wallets.get_used("BTC")
|
||||
|
||||
Reference in New Issue
Block a user