Remove obsolete get_balance method
This commit is contained in:
parent
1465af50d7
commit
63c28b6519
@ -666,17 +666,6 @@ class Exchange:
|
|||||||
|
|
||||||
raise OperationalException(f"stoploss is not implemented for {self.name}.")
|
raise OperationalException(f"stoploss is not implemented for {self.name}.")
|
||||||
|
|
||||||
@retrier
|
|
||||||
def get_balance(self, currency: str) -> float:
|
|
||||||
|
|
||||||
# ccxt exception is already handled by get_balances
|
|
||||||
balances = self.get_balances()
|
|
||||||
balance = balances.get(currency)
|
|
||||||
if balance is None:
|
|
||||||
raise TemporaryError(
|
|
||||||
f'Could not get {currency} balance due to malformed exchange response: {balances}')
|
|
||||||
return balance['free']
|
|
||||||
|
|
||||||
@retrier
|
@retrier
|
||||||
def get_balances(self) -> dict:
|
def get_balances(self) -> dict:
|
||||||
|
|
||||||
|
@ -1248,29 +1248,6 @@ def test_sell_considers_time_in_force(default_conf, mocker, exchange_name):
|
|||||||
assert "timeInForce" not in api_mock.create_order.call_args[0][5]
|
assert "timeInForce" not in api_mock.create_order.call_args[0][5]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
|
||||||
def test_get_balance_prod(default_conf, mocker, exchange_name):
|
|
||||||
api_mock = MagicMock()
|
|
||||||
api_mock.fetch_balance = MagicMock(return_value={'BTC': {'free': 123.4, 'total': 123.4}})
|
|
||||||
default_conf['dry_run'] = False
|
|
||||||
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
|
||||||
|
|
||||||
assert exchange.get_balance(currency='BTC') == 123.4
|
|
||||||
|
|
||||||
with pytest.raises(OperationalException):
|
|
||||||
api_mock.fetch_balance = MagicMock(side_effect=ccxt.BaseError("Unknown error"))
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
|
||||||
|
|
||||||
exchange.get_balance(currency='BTC')
|
|
||||||
|
|
||||||
with pytest.raises(TemporaryError, match=r'.*balance due to malformed exchange response:.*'):
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_balances', MagicMock(return_value={}))
|
|
||||||
mocker.patch('freqtrade.exchange.Kraken.get_balances', MagicMock(return_value={}))
|
|
||||||
exchange.get_balance(currency='BTC')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
||||||
def test_get_balances_prod(default_conf, mocker, exchange_name):
|
def test_get_balances_prod(default_conf, mocker, exchange_name):
|
||||||
balance_item = {
|
balance_item = {
|
||||||
|
@ -82,10 +82,6 @@ def test_bot_cleanup(mocker, default_conf, caplog) -> None:
|
|||||||
def test_order_dict_dry_run(default_conf, mocker, caplog) -> None:
|
def test_order_dict_dry_run(default_conf, mocker, caplog) -> None:
|
||||||
patch_RPCManager(mocker)
|
patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
mocker.patch.multiple(
|
|
||||||
'freqtrade.exchange.Exchange',
|
|
||||||
get_balance=MagicMock(return_value=default_conf['stake_amount'] * 2)
|
|
||||||
)
|
|
||||||
conf = default_conf.copy()
|
conf = default_conf.copy()
|
||||||
conf['runmode'] = RunMode.DRY_RUN
|
conf['runmode'] = RunMode.DRY_RUN
|
||||||
conf['order_types'] = {
|
conf['order_types'] = {
|
||||||
@ -117,10 +113,7 @@ def test_order_dict_dry_run(default_conf, mocker, caplog) -> None:
|
|||||||
def test_order_dict_live(default_conf, mocker, caplog) -> None:
|
def test_order_dict_live(default_conf, mocker, caplog) -> None:
|
||||||
patch_RPCManager(mocker)
|
patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
mocker.patch.multiple(
|
|
||||||
'freqtrade.exchange.Exchange',
|
|
||||||
get_balance=MagicMock(return_value=default_conf['stake_amount'] * 2)
|
|
||||||
)
|
|
||||||
conf = default_conf.copy()
|
conf = default_conf.copy()
|
||||||
conf['runmode'] = RunMode.LIVE
|
conf['runmode'] = RunMode.LIVE
|
||||||
conf['order_types'] = {
|
conf['order_types'] = {
|
||||||
@ -153,10 +146,6 @@ def test_order_dict_live(default_conf, mocker, caplog) -> None:
|
|||||||
def test_get_trade_stake_amount(default_conf, ticker, mocker) -> None:
|
def test_get_trade_stake_amount(default_conf, ticker, mocker) -> None:
|
||||||
patch_RPCManager(mocker)
|
patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
mocker.patch.multiple(
|
|
||||||
'freqtrade.exchange.Exchange',
|
|
||||||
get_balance=MagicMock(return_value=default_conf['stake_amount'] * 2)
|
|
||||||
)
|
|
||||||
|
|
||||||
freqtrade = FreqtradeBot(default_conf)
|
freqtrade = FreqtradeBot(default_conf)
|
||||||
|
|
||||||
@ -181,7 +170,6 @@ def test_check_available_stake_amount(default_conf, ticker, mocker, fee, limit_b
|
|||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
fetch_ticker=ticker,
|
fetch_ticker=ticker,
|
||||||
get_balance=MagicMock(return_value=default_conf['stake_amount'] * 2),
|
|
||||||
buy=MagicMock(return_value=limit_buy_order_open),
|
buy=MagicMock(return_value=limit_buy_order_open),
|
||||||
get_fee=fee
|
get_fee=fee
|
||||||
)
|
)
|
||||||
@ -435,7 +423,6 @@ def test_create_trade_limit_reached(default_conf, ticker, limit_buy_order_open,
|
|||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
fetch_ticker=ticker,
|
fetch_ticker=ticker,
|
||||||
buy=MagicMock(return_value=limit_buy_order_open),
|
buy=MagicMock(return_value=limit_buy_order_open),
|
||||||
get_balance=MagicMock(return_value=default_conf['stake_amount']),
|
|
||||||
get_fee=fee,
|
get_fee=fee,
|
||||||
)
|
)
|
||||||
default_conf['max_open_trades'] = 0
|
default_conf['max_open_trades'] = 0
|
||||||
@ -523,7 +510,6 @@ def test_create_trade_no_signal(default_conf, fee, mocker) -> None:
|
|||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_balance=MagicMock(return_value=20),
|
|
||||||
get_fee=fee,
|
get_fee=fee,
|
||||||
)
|
)
|
||||||
default_conf['stake_amount'] = 10
|
default_conf['stake_amount'] = 10
|
||||||
|
Loading…
Reference in New Issue
Block a user