Implement get_balance and telegram balance formatting

This commit is contained in:
enenn
2018-02-04 11:30:54 +01:00
parent b6c173e3f4
commit 5c7d0ff1df
5 changed files with 63 additions and 58 deletions

View File

@@ -147,7 +147,7 @@ def test_get_balances_dry_run(default_conf, mocker):
default_conf['dry_run'] = True
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
assert get_balances() == []
assert get_balances() == {}
def test_get_balances_prod(default_conf, mocker):

View File

@@ -639,35 +639,31 @@ def test_stop_handle_already_stopped(default_conf, update, mocker):
def test_balance_handle(default_conf, update, mocker):
mock_balance = [{
'Currency': 'BTC',
'Balance': 10.0,
'Available': 12.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
}, {
'Currency': 'ETH',
'Balance': 0.0,
'Available': 0.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
}, {
'Currency': 'USDT',
'Balance': 10000.0,
'Available': 0.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
}, {
'Currency': 'LTC',
'Balance': 10.0,
'Available': 10.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
}]
mock_balance = {
'BTC': {
'total': 12.0,
'free': 12.0,
'used': 0.0,
},
'ETH': {
'total': 0.0,
'free': 0.0,
'used': 0.0,
},
'USDT': {
'total': 10000.0,
'free': 0.0,
'used': 0.0,
},
'LTC': {
'total': 10.0,
'free': 10.0,
'used': 0.0,
}
}
def mock_ticker(symbol, refresh):
if symbol == 'USDT_BTC':
if symbol == 'BTC/USDT':
return {
'bid': 10000.00,
'ask': 10000.00,
@@ -701,7 +697,7 @@ def test_balance_handle(default_conf, update, mocker):
assert '*Currency*: USDT' in result
assert 'Balance' in result
assert 'Est. BTC' in result
assert '*BTC*: 12.00000000' in result
assert '*BTC*: 14.00000000' in result
def test_zero_balance_handle(default_conf, update, mocker):
@@ -712,7 +708,7 @@ def test_zero_balance_handle(default_conf, update, mocker):
init=MagicMock(),
send_msg=msg_mock)
mocker.patch.multiple('freqtrade.main.exchange',
get_balances=MagicMock(return_value=[]))
get_balances=MagicMock(return_value={}))
_balance(bot=MagicMock(), update=update)
result = msg_mock.call_args_list[0][0][0]
assert msg_mock.call_count == 1

View File

@@ -161,7 +161,7 @@ def test_load_config(default_conf, mocker):
def test_load_config_invalid_pair(default_conf, mocker):
conf = deepcopy(default_conf)
conf['exchange']['pair_whitelist'].append('ETH/BTC')
conf['exchange']['pair_whitelist'].append('ETH_BTC') # Should have format ETH/BTC
mocker.patch(
'freqtrade.misc.open',
mocker.mock_open(