Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kucoin - with order_refresh_time (15mins or more) got OSError executing request, error code 400002 Invalid KC-API-TIMESTAMP #6866

Closed
rapcmia opened this issue Feb 22, 2024 · 1 comment

Comments

@rapcmia
Copy link
Contributor

rapcmia commented Feb 22, 2024

Describe the bug

When running test on kucoin spot, we observed instances of these errors while the connector was fetching trade updates, balances or trying to cancel an active order

Failed to fetch trade updates:

2024-02-22 14:59:16,360 - 71791 - hummingbot.connector.exchange.kucoin.kucoin_exchange.KucoinExchange - WARNING - Failed to fetch trade updates. Error: Error executing request GET https://api.kucoin.com/api/v1/fills. HTTP status is 400. Error: {"code":"400002","msg":"Invalid KC-API-TIMESTAMP"}

Failed to cancel order:

2024-02-22 15:17:04,438 - 71791 - hummingbot.connector.exchange.kucoin.kucoin_exchange.KucoinExchange - ERROR - Failed to cancel order BSLUT611f300c7f139e43fde9f696090a26c784d
Traceback (most recent call last):
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange_py_base.py", line 520, in _execute_order_cancel
    cancelled = await self._execute_order_cancel_and_process_update(order=order)
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange_py_base.py", line 540, in _execute_order_cancel_and_process_update
    cancelled = await self._place_cancel(order.client_order_id, order)
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange/kucoin/kucoin_exchange.py", line 226, in _place_cancel
    cancel_result = await self._api_delete(
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange_py_base.py", line 875, in _api_delete
    return await self._api_request(*args, **kwargs)
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange_py_base.py", line 905, in _api_request
    request_result = await rest_assistant.execute_request(
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/core/web_assistant/rest_assistant.py", line 47, in execute_request
    response = await self.execute_request_and_get_response(
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/core/web_assistant/rest_assistant.py", line 99, in execute_request_and_get_response
    raise IOError(f"Error executing request {method.name} {url}. HTTP status is {response.status}. "
OSError: Error executing request DELETE https://api.kucoin.com/api/v1/orders/65d6f1206100db0007218806. HTTP status is 400. Error: {"code":"400002","msg":"Invalid KC-API-TIMESTAMP"}

Failed to update balance:

2024-02-22 17:09:16,591 - 71791 - hummingbot.connector.exchange.kucoin.kucoin_exchange.KucoinExchange - WARNING - Failed to update balances. Error: Error executing request GET https://api.kucoin.com/api/v1/accounts. HTTP status is 400. Error: {"code":"400002","msg":"Invalid KC-API-TIMESTAMP"}
Traceback (most recent call last):
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange_py_base.py", line 938, in _update_all_balances
    await self._update_balances()
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange/kucoin/kucoin_exchange.py", line 320, in _update_balances
    response = await self._api_get(
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange_py_base.py", line 863, in _api_get
    return await self._api_request(*args, **kwargs)
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/connector/exchange_py_base.py", line 905, in _api_request
    request_result = await rest_assistant.execute_request(
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/core/web_assistant/rest_assistant.py", line 47, in execute_request
    response = await self.execute_request_and_get_response(
  File "/Users/rapcomia/github/hummingbot/staging/hummingbot/core/web_assistant/rest_assistant.py", line 99, in execute_request_and_get_response
    raise IOError(f"Error executing request {method.name} {url}. HTTP status is {response.status}. "
OSError: Error executing request GET https://api.kucoin.com/api/v1/accounts. HTTP status is 400. Error: {"code":"400002","msg":"Invalid KC-API-TIMESTAMP"}
  • On the attached log file:
    • 2024-02-22 17:57:19,179 - Failed to cancel error occurred
    • 2024-02-22 18:02:24,273 - Connector fixed itself and orders canceled successfully
    • Took 5mins to cancel orders ok and seen happened again on later timeframes
    • This is also observed when stop command is initiated causing orders to be stuck on exchange.
      • Tried to run again stop command so it can try to recheck active orders but still same error

Steps to reproduce

  1. Add Kucoin spot API keys
  2. Setup a v1(Pure Market Making) or v2 strategy script with long refresh time (15mins or more)
  3. Start and observe after couple of hours

Release version

dev-1.25.0

Type of installation

Source

Attach required files

logs_pmm-kucoin1.log

@nikspz nikspz changed the title Kucoin - OSError executing request, error code 400002 Invalid KC-API-TIMESTAMP Kucoin - with order_refresh_time (15mins or more) got OSError executing request, error code 400002 Invalid KC-API-TIMESTAMP Feb 22, 2024
@rapcmia
Copy link
Contributor Author

rapcmia commented Apr 18, 2024

Not able to reproduce after testing 3/3 local and cloud

@rapcmia rapcmia closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant