fixed test_load_leverage_tiers
This commit is contained in:
parent
183f85efe3
commit
c70050e750
@ -248,6 +248,7 @@ class Binance(Exchange):
|
||||
|
||||
@retrier
|
||||
def load_leverage_tiers(self) -> Dict[str, List[Dict]]:
|
||||
if self.trading_mode == TradingMode.FUTURES:
|
||||
if self._config['dry_run']:
|
||||
leverage_tiers_path = (
|
||||
Path(__file__).parent / 'binance_leverage_tiers.json'
|
||||
@ -264,3 +265,5 @@ class Binance(Exchange):
|
||||
f'{e.__class__.__name__}. Message: {e}') from e
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
else:
|
||||
return {}
|
||||
|
@ -4236,14 +4236,15 @@ def test_get_max_pair_stake_amount(
|
||||
assert exchange.get_max_pair_stake_amount('ADA/USDT', 2.0) == 500
|
||||
|
||||
|
||||
def test_load_leverage_tiers(mocker, default_conf, leverage_tiers):
|
||||
@pytest.mark.parametrize('exchange_name', EXCHANGES)
|
||||
def test_load_leverage_tiers(mocker, default_conf, leverage_tiers, exchange_name):
|
||||
api_mock = MagicMock()
|
||||
api_mock.fetch_leverage_tiers = MagicMock()
|
||||
type(api_mock).has = PropertyMock(return_value={'fetchLeverageTiers': True})
|
||||
default_conf['dry_run'] = False
|
||||
mocker.patch('freqtrade.exchange.exchange.Exchange.validate_trading_mode_and_margin_mode')
|
||||
|
||||
api_mock.fetch_leverage_tiers = MagicMock(return_value=[
|
||||
{
|
||||
api_mock.fetch_leverage_tiers = MagicMock(return_value={
|
||||
'ADA/USDT:USDT': [
|
||||
{
|
||||
'tier': 1,
|
||||
@ -4266,24 +4267,23 @@ def test_load_leverage_tiers(mocker, default_conf, leverage_tiers):
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
# SPOT
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock)
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
||||
assert exchange.load_leverage_tiers() == {}
|
||||
|
||||
# FUTURES has.fetchLeverageTiers == False
|
||||
default_conf['trading_mode'] = 'futures'
|
||||
default_conf['margin_mode'] = 'isolated'
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock)
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
||||
type(api_mock).has = PropertyMock(return_value={'fetchLeverageTiers': False})
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock)
|
||||
assert exchange.load_leverage_tiers() == {}
|
||||
|
||||
# FUTURES regular
|
||||
type(api_mock).has = PropertyMock(return_value={'fetchLeverageTiers': True})
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock)
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
||||
assert exchange.load_leverage_tiers() == {
|
||||
'ADA/USDT:USDT': [
|
||||
{
|
||||
@ -4313,7 +4313,7 @@ def test_load_leverage_tiers(mocker, default_conf, leverage_tiers):
|
||||
mocker,
|
||||
default_conf,
|
||||
api_mock,
|
||||
"ftx",
|
||||
exchange_name,
|
||||
"load_leverage_tiers",
|
||||
"fetch_leverage_tiers",
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user