这是indexloc提供的服务,不要输入任何密码
Skip to content

fix/add_retry_logic_for_okx_perpetual_funding-info_retrieval #7602

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

Open
wants to merge 7 commits into
base: development
Choose a base branch
from

Conversation

AilvenLiu
Copy link

Before submitting this PR, please make sure:

  • [Yes] Your code builds clean without any errors or warnings
  • [No ] Tests all pass
  • [Yes] You are using approved title ("feat/", "fix/", "docs/", "refactor/")

A description of the changes proposed in the pull request:
Problems discovered by chance: When using okx_perpetual as the connector for strategic trading, There is a probability that the entire strategy robot cannot operate normally due to the failure of the funding info request (print Connector Not Ready per on tick). This might be related to the startup time. Since the strategy failed stably around the time period of 15:09:18UTC+0, 8th May, 2025, but a similar error has never occurred before. This situation where the entire strategy fails to start due to a single error can be completely avoided by adding retries.

2025-05-08 15:09:18,023 - 46736 - hummingbot.core.utils.async_utils - ERROR - Unhandled error in background task: Error executing request GET https://www.okx.com/api/v5/public/funding-rate. HTTP status is 429. Error: {"msg":"Too Many Requests","code":"50011"}
Traceback (most recent call last):
  File "/home/ubuntu/hummingbot/hummingbot/core/utils/async_utils.py", line 9, in safe_wrapper
    return await c
  File "/home/ubuntu/hummingbot/hummingbot/connector/perpetual_derivative_py_base.py", line 364, in _listen_for_funding_info
    await self._init_funding_info()
  File "/home/ubuntu/hummingbot/hummingbot/connector/perpetual_derivative_py_base.py", line 371, in _init_funding_info
    funding_info = await self._orderbook_ds.get_funding_info(trading_pair)
  File "/home/ubuntu/hummingbot/hummingbot/connector/derivative/okx_perpetual/okx_perpetual_api_order_book_data_source.py", line 122, in get_funding_info
    funding_info_response = await self._request_complete_funding_info(trading_pair)
  File "/home/ubuntu/hummingbot/hummingbot/connector/derivative/okx_perpetual/okx_perpetual_api_order_book_data_source.py", line 193, in _request_complete_funding_info
    responses = await asyncio.gather(*tasks)
  File "/home/ubuntu/hummingbot/hummingbot/core/web_assistant/rest_assistant.py", line 47, in execute_request
    response = await self.execute_request_and_get_response(
  File "/home/ubuntu/hummingbot/hummingbot/core/web_assistant/rest_assistant.py", line 100, 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://www.okx.com/api/v5/public/funding-rate. HTTP status is 429. Error: {"msg":"Too Many Requests","code":"50011"}

Tests performed by the developer:
After adding retries, the strategy was repeatedly started in the same environment and with the same parameters, and no similar errors continued to occur or other errors were introduced

Tips for QA testing:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant