❓ How can I fix this OKEX ExchangeError?
WANGLULU9802 opened this issue · comments
When I use the OKEX exchange, the following error occurs:
INFO - Strategy using timeframe: 5m
INFO - Strategy using stoploss: -0.099
INFO - Strategy using trailing_stop: True
INFO - Strategy using trailing_stop_positive: 0.039
INFO - Strategy using trailing_stop_positive_offset: 0.132
INFO - Strategy using trailing_only_offset_is_reached: False
INFO - Strategy using use_custom_stoploss: True
INFO - Strategy using process_only_new_candles: False
INFO - Strategy using order_types: {'buy': 'limit', 'sell': 'limit', 'emergencysell': 'market', 'forcesell': 'market', 'forcebuy': 'market', 'stoploss': 'market', 'stoploss_on_exchange': False, 'stoploss_on_exchange_interval': 60}
INFO - Strategy using order_time_in_force: {'buy': 'gtc', 'sell': 'gtc'}
INFO - Strategy using stake_currency: USDT
INFO - Strategy using stake_amount: 45
INFO - Strategy using protections: [{'method': 'StoplossGuard', 'lookback_period': 1440, 'trade_limit': 10, 'stop_duration': 1440, 'only_per_pair': False}, {'method': 'StoplossGuard', 'lookback_period': 1440, 'trade_limit': 2, 'stop_duration': 1440, 'only_per_pair': True}]
INFO - Strategy using startup_candle_count: 400
INFO - Strategy using unfilledtimeout: {'buy': 10, 'sell': 30, 'unit': 'minutes'}
INFO - Strategy using use_sell_signal: True
INFO - Strategy using sell_profit_only: False
INFO - Strategy using ignore_roi_if_buy_signal: True
INFO - Strategy using sell_profit_offset: 0
INFO - Strategy using disable_dataframe_checks: False
INFO - Strategy using ignore_buying_expired_candle_after: 0
INFO - Validating configuration ...
INFO - No Okex specific subclass found. Using the generic class instead.
INFO - Using CCXT 1.52.4
INFO - Applying additional ccxt config: {'enableRateLimit': True}
INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 500, 'aiohttp_trust_env': False}
INFO - Using Exchange "OKEX"
WARNING - get_balances() returned exception: "Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}"
WARNING - retrying get_balances() still for 4 times
WARNING - get_balances() returned exception: "Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}"
WARNING - retrying get_balances() still for 3 times
WARNING - get_balances() returned exception: "Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}"
WARNING - retrying get_balances() still for 2 times
WARNING - get_balances() returned exception: "Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}"
WARNING - retrying get_balances() still for 1 times
WARNING - get_balances() returned exception: "Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}"
WARNING - Giving up retrying: get_balances()
ERROR - Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
ERROR - Fatal exception!
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 593, in fetch
response.raise_for_status()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: for url: https://www.okex.com/api/spot/v3/accounts
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 901, in get_balances
balances = self._api.fetch_balance()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 1730, in fetch_balance
response = getattr(self, method)(query)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 461, in inner
return entry(_self, **inner_kwargs)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 486, in request
return self.fetch2(path, api, method, params, headers, body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 482, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 609, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 3514, in handle_errors
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 500, in throw_exactly_matched_exception
raise exact[string](message)
ccxt.base.errors.ExchangeError: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 89, in wrapper
return f(*args, **kwargs)
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 912, in get_balances
raise TemporaryError(
freqtrade.exceptions.TemporaryError: Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 593, in fetch
response.raise_for_status()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: for url: https://www.okex.com/api/spot/v3/accounts
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 901, in get_balances
balances = self._api.fetch_balance()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 1730, in fetch_balance
response = getattr(self, method)(query)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 461, in inner
return entry(_self, **inner_kwargs)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 486, in request
return self.fetch2(path, api, method, params, headers, body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 482, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 609, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 3514, in handle_errors
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 500, in throw_exactly_matched_exception
raise exact[string](message)
ccxt.base.errors.ExchangeError: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 89, in wrapper
return f(*args, **kwargs)
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 912, in get_balances
raise TemporaryError(
freqtrade.exceptions.TemporaryError: Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 593, in fetch
response.raise_for_status()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: for url: https://www.okex.com/api/spot/v3/accounts
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 901, in get_balances
balances = self._api.fetch_balance()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 1730, in fetch_balance
response = getattr(self, method)(query)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 461, in inner
return entry(_self, **inner_kwargs)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 486, in request
return self.fetch2(path, api, method, params, headers, body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 482, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 609, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 3514, in handle_errors
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 500, in throw_exactly_matched_exception
raise exact[string](message)
ccxt.base.errors.ExchangeError: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 89, in wrapper
return f(*args, **kwargs)
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 912, in get_balances
raise TemporaryError(
freqtrade.exceptions.TemporaryError: Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 593, in fetch
response.raise_for_status()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: for url: https://www.okex.com/api/spot/v3/accounts
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 901, in get_balances
balances = self._api.fetch_balance()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 1730, in fetch_balance
response = getattr(self, method)(query)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 461, in inner
return entry(_self, **inner_kwargs)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 486, in request
return self.fetch2(path, api, method, params, headers, body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 482, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 609, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 3514, in handle_errors
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 500, in throw_exactly_matched_exception
raise exact[string](message)
ccxt.base.errors.ExchangeError: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 89, in wrapper
return f(*args, **kwargs)
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 912, in get_balances
raise TemporaryError(
freqtrade.exceptions.TemporaryError: Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 593, in fetch
response.raise_for_status()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: for url: https://www.okex.com/api/spot/v3/accounts
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 901, in get_balances
balances = self._api.fetch_balance()
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 1730, in fetch_balance
response = getattr(self, method)(query)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 461, in inner
return entry(_self, **inner_kwargs)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 486, in request
return self.fetch2(path, api, method, params, headers, body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 482, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 609, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/okex.py", line 3514, in handle_errors
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
File "/usr/local/src/Freqtrade-MGM/.env/lib/python3.8/site-packages/ccxt/base/exchange.py", line 500, in throw_exactly_matched_exception
raise exact[string](message)
ccxt.base.errors.ExchangeError: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/src/Freqtrade-MGM/freqtrade/commands/trade_commands.py", line 18, in start_trading
worker = Worker(args)
File "/usr/local/src/Freqtrade-MGM/freqtrade/worker.py", line 35, in __init__
self._init(False)
File "/usr/local/src/Freqtrade-MGM/freqtrade/worker.py", line 52, in _init
self.freqtrade = FreqtradeBot(self._config)
File "/usr/local/src/Freqtrade-MGM/freqtrade/freqtradebot.py", line 69, in __init__
self.wallets = Wallets(self.config, self.exchange)
File "/usr/local/src/Freqtrade-MGM/freqtrade/wallets.py", line 37, in __init__
self.update()
File "/usr/local/src/Freqtrade-MGM/freqtrade/wallets.py", line 124, in update
self._update_live()
File "/usr/local/src/Freqtrade-MGM/freqtrade/wallets.py", line 99, in _update_live
balances = self._exchange.get_balances()
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 101, in wrapper
return wrapper(*args, **kwargs)
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 101, in wrapper
return wrapper(*args, **kwargs)
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 101, in wrapper
return wrapper(*args, **kwargs)
[Previous line repeated 1 more time]
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 104, in wrapper
raise ex
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/common.py", line 89, in wrapper
return f(*args, **kwargs)
File "/usr/local/src/Freqtrade-MGM/freqtrade/exchange/exchange.py", line 912, in get_balances
raise TemporaryError(
freqtrade.exceptions.TemporaryError: Could not get balance due to ExchangeError. Message: okex {"error_message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.","code":30016,"error_code":"30016","message":"Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."}
Hi @WANGLULU9802,
I'm not familiar with OKEX myself yet, however I noticed that Freqtrade added support for it recently.
You're the first to test this with MGM to my knowledge, but I'll try to help you as well as I can.
I notice following exception occuring various times in the stack-trace you posted above:
exception: "Could not get balance due to ExchangeError. Message: okex:
{
"error_message": "Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey.",
"code": 30016,
"error_code": "30016",
"message": "Please change to port v1 when you are using v1 apiKey. If you wish to use port v3, please register a v3 apiKey."
}
So I would check on OKEX if you can generate a v3 API Key, and then use that instead.
A.t.m. it looks like you're still using an older v1 API Key which appears to be giving issues with Freqtrade,
which seems to be using v3 for it's ports by default.
Also make sure to read the Official Freqtrade OKEX Exchange specific notes, so that you're sure that your mgm-config-private
is configured correctly for it.