Merge pull request #2227 from freqtrade/fix/balance_failure
Fix RPC /balance failure
This commit is contained in:
commit
df481eb642
@ -30,6 +30,9 @@ BAD_EXCHANGES = {
|
|||||||
"bitmex": "Various reasons",
|
"bitmex": "Various reasons",
|
||||||
"bitstamp": "Does not provide history. "
|
"bitstamp": "Does not provide history. "
|
||||||
"Details in https://github.com/freqtrade/freqtrade/issues/1983",
|
"Details in https://github.com/freqtrade/freqtrade/issues/1983",
|
||||||
|
"kraken": "TEMPORARY: Balance does not report free balance, so freqtrade will not know "
|
||||||
|
"if enough balance is available."
|
||||||
|
"Details in https://github.com/freqtrade/freqtrade/issues/1687#issuecomment-528509266"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,9 +294,9 @@ class RPC(object):
|
|||||||
total = total + est_btc
|
total = total + est_btc
|
||||||
output.append({
|
output.append({
|
||||||
'currency': coin,
|
'currency': coin,
|
||||||
'available': balance['free'],
|
'free': balance['free'] if balance['free'] is not None else 0,
|
||||||
'balance': balance['total'],
|
'balance': balance['total'] if balance['total'] is not None else 0,
|
||||||
'pending': balance['used'],
|
'used': balance['used'] if balance['used'] is not None else 0,
|
||||||
'est_btc': est_btc,
|
'est_btc': est_btc,
|
||||||
})
|
})
|
||||||
if total == 0.0:
|
if total == 0.0:
|
||||||
|
@ -328,9 +328,9 @@ class Telegram(RPC):
|
|||||||
for currency in result['currencies']:
|
for currency in result['currencies']:
|
||||||
if currency['est_btc'] > 0.0001:
|
if currency['est_btc'] > 0.0001:
|
||||||
curr_output = "*{currency}:*\n" \
|
curr_output = "*{currency}:*\n" \
|
||||||
"\t`Available: {available: .8f}`\n" \
|
"\t`Available: {free: .8f}`\n" \
|
||||||
"\t`Balance: {balance: .8f}`\n" \
|
"\t`Balance: {balance: .8f}`\n" \
|
||||||
"\t`Pending: {pending: .8f}`\n" \
|
"\t`Pending: {used: .8f}`\n" \
|
||||||
"\t`Est. BTC: {est_btc: .8f}`\n".format(**currency)
|
"\t`Est. BTC: {est_btc: .8f}`\n".format(**currency)
|
||||||
else:
|
else:
|
||||||
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
||||||
|
@ -363,9 +363,9 @@ def test_rpc_balance_handle_error(default_conf, mocker):
|
|||||||
assert 'USD' == result['symbol']
|
assert 'USD' == result['symbol']
|
||||||
assert result['currencies'] == [{
|
assert result['currencies'] == [{
|
||||||
'currency': 'BTC',
|
'currency': 'BTC',
|
||||||
'available': 10.0,
|
'free': 10.0,
|
||||||
'balance': 12.0,
|
'balance': 12.0,
|
||||||
'pending': 2.0,
|
'used': 2.0,
|
||||||
'est_btc': 12.0,
|
'est_btc': 12.0,
|
||||||
}]
|
}]
|
||||||
assert result['total'] == 12.0
|
assert result['total'] == 12.0
|
||||||
@ -417,22 +417,22 @@ def test_rpc_balance_handle(default_conf, mocker):
|
|||||||
assert 'USD' == result['symbol']
|
assert 'USD' == result['symbol']
|
||||||
assert result['currencies'] == [
|
assert result['currencies'] == [
|
||||||
{'currency': 'BTC',
|
{'currency': 'BTC',
|
||||||
'available': 10.0,
|
'free': 10.0,
|
||||||
'balance': 12.0,
|
'balance': 12.0,
|
||||||
'pending': 2.0,
|
'used': 2.0,
|
||||||
'est_btc': 12.0,
|
'est_btc': 12.0,
|
||||||
},
|
},
|
||||||
{'available': 1.0,
|
{'free': 1.0,
|
||||||
'balance': 5.0,
|
'balance': 5.0,
|
||||||
'currency': 'ETH',
|
'currency': 'ETH',
|
||||||
'est_btc': 0.05,
|
'est_btc': 0.05,
|
||||||
'pending': 4.0
|
'used': 4.0
|
||||||
},
|
},
|
||||||
{'available': 5.0,
|
{'free': 5.0,
|
||||||
'balance': 10.0,
|
'balance': 10.0,
|
||||||
'currency': 'PAX',
|
'currency': 'PAX',
|
||||||
'est_btc': 0.1,
|
'est_btc': 0.1,
|
||||||
'pending': 5.0}
|
'used': 5.0}
|
||||||
]
|
]
|
||||||
assert result['total'] == 12.15
|
assert result['total'] == 12.15
|
||||||
|
|
||||||
|
@ -251,9 +251,9 @@ def test_api_balance(botclient, mocker, rpc_balance):
|
|||||||
assert len(rc.json["currencies"]) == 5
|
assert len(rc.json["currencies"]) == 5
|
||||||
assert rc.json['currencies'][0] == {
|
assert rc.json['currencies'][0] == {
|
||||||
'currency': 'BTC',
|
'currency': 'BTC',
|
||||||
'available': 12.0,
|
'free': 12.0,
|
||||||
'balance': 12.0,
|
'balance': 12.0,
|
||||||
'pending': 0.0,
|
'used': 0.0,
|
||||||
'est_btc': 12.0,
|
'est_btc': 12.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,8 +577,8 @@ def test_balance_handle_too_large_response(default_conf, update, mocker) -> None
|
|||||||
curr = choice(ascii_uppercase) + choice(ascii_uppercase) + choice(ascii_uppercase)
|
curr = choice(ascii_uppercase) + choice(ascii_uppercase) + choice(ascii_uppercase)
|
||||||
balances.append({
|
balances.append({
|
||||||
'currency': curr,
|
'currency': curr,
|
||||||
'available': 1.0,
|
'free': 1.0,
|
||||||
'pending': 0.5,
|
'used': 0.5,
|
||||||
'balance': i,
|
'balance': i,
|
||||||
'est_btc': 1
|
'est_btc': 1
|
||||||
})
|
})
|
||||||
|
@ -494,7 +494,7 @@ def test_check_exchange(default_conf, caplog) -> None:
|
|||||||
caplog.clear()
|
caplog.clear()
|
||||||
|
|
||||||
# Test an available exchange, supported by ccxt
|
# Test an available exchange, supported by ccxt
|
||||||
default_conf.get('exchange').update({'name': 'kraken'})
|
default_conf.get('exchange').update({'name': 'huobipro'})
|
||||||
assert check_exchange(default_conf)
|
assert check_exchange(default_conf)
|
||||||
assert log_has_re(r"Exchange .* is supported by ccxt and .* not officially supported "
|
assert log_has_re(r"Exchange .* is supported by ccxt and .* not officially supported "
|
||||||
r"by the Freqtrade development team\. .*", caplog)
|
r"by the Freqtrade development team\. .*", caplog)
|
||||||
|
Loading…
Reference in New Issue
Block a user