Only fetch accounts when authenticated.
This commit is contained in:
parent
149704e748
commit
dc0c1bf87d
@ -45,7 +45,7 @@ class Okx(Exchange):
|
|||||||
Must be overridden in child methods if required.
|
Must be overridden in child methods if required.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if self.trading_mode == TradingMode.FUTURES:
|
if self.trading_mode == TradingMode.FUTURES and not self._config['dry_run']:
|
||||||
accounts = self._api.fetch_accounts()
|
accounts = self._api.fetch_accounts()
|
||||||
if len(accounts) > 0:
|
if len(accounts) > 0:
|
||||||
self.net_only = accounts[0].get('info', {}).get('posMode') == 'net_mode'
|
self.net_only = accounts[0].get('info', {}).get('posMode') == 'net_mode'
|
||||||
|
@ -135,6 +135,7 @@ def exchange_futures(request, exchange_conf, class_mocker):
|
|||||||
class_mocker.patch(
|
class_mocker.patch(
|
||||||
'freqtrade.exchange.binance.Binance.fill_leverage_tiers')
|
'freqtrade.exchange.binance.Binance.fill_leverage_tiers')
|
||||||
class_mocker.patch('freqtrade.exchange.exchange.Exchange.fetch_trading_fees')
|
class_mocker.patch('freqtrade.exchange.exchange.Exchange.fetch_trading_fees')
|
||||||
|
class_mocker.patch('freqtrade.exchange.okx.Okx.additional_exchange_init')
|
||||||
exchange = ExchangeResolver.load_exchange(request.param, exchange_conf, validate=True)
|
exchange = ExchangeResolver.load_exchange(request.param, exchange_conf, validate=True)
|
||||||
|
|
||||||
yield exchange, request.param
|
yield exchange, request.param
|
||||||
|
@ -205,6 +205,7 @@ def test_additional_exchange_init_okx(default_conf, mocker):
|
|||||||
'mgnIsoMode': 'automatic',
|
'mgnIsoMode': 'automatic',
|
||||||
'posMode': 'long_short_mode',
|
'posMode': 'long_short_mode',
|
||||||
'uid': '2555'}}])
|
'uid': '2555'}}])
|
||||||
|
default_conf['dry_run'] = False
|
||||||
exchange = get_patched_exchange(mocker, default_conf, id="okx", api_mock=api_mock)
|
exchange = get_patched_exchange(mocker, default_conf, id="okx", api_mock=api_mock)
|
||||||
assert api_mock.fetch_accounts.call_count == 0
|
assert api_mock.fetch_accounts.call_count == 0
|
||||||
exchange.trading_mode = TradingMode.FUTURES
|
exchange.trading_mode = TradingMode.FUTURES
|
||||||
|
Loading…
Reference in New Issue
Block a user