Improve /balance output to include starting balance and percentual change

closes #5503
This commit is contained in:
Matthias
2021-09-19 13:16:30 +02:00
parent c1895a0fc2
commit ab88217186
5 changed files with 54 additions and 16 deletions

View File

@@ -422,20 +422,22 @@ def test_api_stopbuy(botclient):
assert ftbot.config['max_open_trades'] == 0
def test_api_balance(botclient, mocker, rpc_balance):
def test_api_balance(botclient, mocker, rpc_balance, tickers):
ftbot, client = botclient
ftbot.config['dry_run'] = False
mocker.patch('freqtrade.exchange.Exchange.get_balances', return_value=rpc_balance)
mocker.patch('freqtrade.exchange.Exchange.get_tickers', tickers)
mocker.patch('freqtrade.exchange.Exchange.get_valid_pair_combination',
side_effect=lambda a, b: f"{a}/{b}")
ftbot.wallets.update()
rc = client_get(client, f"{BASE_URI}/balance")
assert_response(rc)
assert "currencies" in rc.json()
assert len(rc.json()["currencies"]) == 5
assert rc.json()['currencies'][0] == {
response = rc.json()
assert "currencies" in response
assert len(response["currencies"]) == 5
assert response['currencies'][0] == {
'currency': 'BTC',
'free': 12.0,
'balance': 12.0,
@@ -443,6 +445,10 @@ def test_api_balance(botclient, mocker, rpc_balance):
'est_stake': 12.0,
'stake': 'BTC',
}
assert 'starting_capital' in response
assert 'starting_capital_fiat' in response
assert 'starting_capital_pct' in response
assert 'starting_capital_ratio' in response
def test_api_count(botclient, mocker, ticker, fee, markets):

View File

@@ -576,6 +576,8 @@ def test_balance_handle_too_large_response(default_conf, update, mocker) -> None
'total': 100.0,
'symbol': 100.0,
'value': 1000.0,
'starting_capital': 1000,
'starting_capital_fiat': 1000,
})
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)