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

Feat/xemm executor #6946

Merged
merged 73 commits into from
Apr 22, 2024
Merged

Conversation

cardosofede
Copy link
Contributor

Before submitting this PR, please make sure:

  • Your code builds clean without any errors or warnings
  • You are using approved title ("feat/", "fix/", "docs/", "refactor/")

A description of the changes proposed in the pull request:

Tests performed by the developer:

Tips for QA testing:

@rapcmia rapcmia self-requested a review April 3, 2024 03:43
@rapcmia
Copy link
Contributor

rapcmia commented Apr 19, 2024

PR update on commit 5f18eec4353e485113197316ad2e338b4c6bdd3b

  • 12 hours running bot on okx/binance (maker/taker)
  • Maker limit orders are created on each order level
    • There was disconnection from okx connector resulting the active order failed for fetching updates
      # Created market limit order 93027a12dac34fBCSGSUT8b497d41571
      2024-04-18 19:53:26,029 - 1301374 - hummingbot.strategy.script_strategy_base - INFO - Creating GAS-USDT sell order: price: 5.309086050052325229565909866 amount: 2.285496619369583849157223122.
      2024-04-18 19:53:26,030 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - INFO - Created maker order 93027a12dac34fBCSGSUT8b497d41571 at price 5.309086050052325229565909866.
      2024-04-18 19:53:26,464 - 1301374 - hummingbot.connector.client_order_tracker - INFO - Created LIMIT SELL order 93027a12dac34fBCSGSUT8b497d41571 for 2.285496 GAS-USDT.
      2024-04-18 19:53:26,464 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - INFO - Maker order 93027a12dac34fBCSGSUT8b497d41571 created.
      2024-04-18 19:53:26,476 - 1301374 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1713470006.0, "type": "OrderType.LIMIT", "trading_pair": "GAS-USDT", "amount": "2.285496", "price": "5.309", "order_id": "93027a12dac34fBCSGSUT8b497d41571", "creation_timestamp": 1713470006.0, "exchange_order_id": "701279265618657285", "leverage": 1, "position": "NIL", "event_name": "SellOrderCreatedEvent", "event_source": "okx"}
      
      # Connector got disconnected 
      2024-04-18 19:54:09,278 - 1301374 - hummingbot.connector.exchange.okx.okx_exchange.OkxExchange - INFO - Network status has changed to NetworkStatus.NOT_CONNECTED. Stopping networking...
      2024-04-18 19:55:04,303 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - INFO - Trade profitability 0.01001308961321099329175980914 is above target profitability. Cancelling order.
      2024-04-18 19:55:04,304 - 1301374 - hummingbot.strategy.script_strategy_base - INFO - (GAS-USDT) Canceling the limit order 93027a12dac34fBCSGSUT8b497d41571. [clock=2024-04-18 19:55:04+00:00]
      2024-04-18 19:55:04,677 - 1301374 - hummingbot.connector.exchange.okx.okx_exchange.OkxExchange - ERROR - Failed to cancel order 93027a12dac34fBCSGSUT8b497d41571
      Traceback (most recent call last):
        File "/home/ralph/github/hummingbot/6946/hummingbot/connector/exchange_py_base.py", line 520, in _execute_order_cancel
          cancelled = await self._execute_order_cancel_and_process_update(order=order)
        File "/home/ralph/github/hummingbot/6946/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 "/home/ralph/github/hummingbot/6946/hummingbot/connector/exchange/okx/okx_exchange.py", line 219, in _place_cancel
          cancel_result = await self._api_post(
        File "/home/ralph/github/hummingbot/6946/hummingbot/connector/exchange_py_base.py", line 867, in _api_post
          return await self._api_request(*args, **kwargs)
        File "/home/ralph/github/hummingbot/6946/hummingbot/connector/exchange_py_base.py", line 906, in _api_request
          request_result = await rest_assistant.execute_request(
        File "/home/ralph/github/hummingbot/6946/hummingbot/core/web_assistant/rest_assistant.py", line 47, in execute_request
          response = await self.execute_request_and_get_response(
        File "/home/ralph/github/hummingbot/6946/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 POST https://www.okx.com/api/v5/trade/cancel-order. HTTP status is 403. Error: N/A
      # trimmed timestamp
      
      # market limit order has been filled 
      2024-04-18 21:14:00,028 - 1301374 - hummingbot.connector.client_order_tracker - INFO - The SELL order 93027a12dac34fBCSGSUT8b497d41571 amounting to 2.28549/2.285496 GAS has been filled.
      2024-04-18 21:14:00,102 - 1301374 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1713474840.0, "order_id": "93027a12dac34fBCSGSUT8b497d41571", "trading_pair": "GAS-USDT", "trade_type": "TradeType.SELL", "order_type": "OrderType.LIMIT", "price": "5.309", "amount": "2.28549", "trade_fee": {"percent": "0", "percent_token": "USDT", "flat_fees": [{"token": "USDT", "amount": "-0.009706933128"}]}, "exchange_trade_id": "16632644", "exchange_order_id": "701279265618657285", "leverage": 1, "position": "NIL", "event_name": "OrderFilledEvent", "event_source": "okx"}
      2024-04-18 21:14:00,112 - 1301374 - hummingbot.connector.client_order_tracker - INFO - The SELL order 93027a12dac34fBCSGSUT8b497d41571 amounting to 2.285496/2.285496 GAS has been filled.
      2024-04-18 21:14:00,139 - 1301374 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1713474840.0, "order_id": "93027a12dac34fBCSGSUT8b497d41571", "trading_pair": "GAS-USDT", "trade_type": "TradeType.SELL", "order_type": "OrderType.LIMIT", "price": "5.309", "amount": "0.000006", "trade_fee": {"percent": "0", "percent_token": "USDT", "flat_fees": [{"token": "USDT", "amount": "-2.54832E-8"}]}, "exchange_trade_id": "16632645", "exchange_order_id": "701279265618657285", "leverage": 1, "position": "NIL", "event_name": "OrderFilledEvent", "event_source": "okx"}
      2024-04-18 21:14:00,563 - 1301374 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1713474840.0, "order_id": "93027a12dac34fBCSGSUT8b497d41571", "base_asset": "GAS", "quote_asset": "USDT", "base_asset_amount": "2.285496", "quote_asset_amount": "12.133698264", "order_type": "OrderType.LIMIT", "exchange_order_id": "701279265618657285", "event_name": "SellOrderCompletedEvent", "event_source": "okx"}
      2024-04-18 21:14:00,563 - 1301374 - hummingbot.connector.client_order_tracker - INFO - SELL order 93027a12dac34fBCSGSUT8b497d41571 completely filled.
      
      • The executor does not seem to recognize the market order filled therefore no taker order event happened
    • Taker market orders completed on each order level
    • Executors are completed with no errors found
    • There are instance of partial fills and worked ok
    • Script returns failed to submit order on maker when insufficient balance
    • When taker exchange assets has been rebalance,
      • When either base or quote asset is insufficient for order creation script would return on logs Not enough budget to open position.
      2024-04-19 02:31:12,592 - 1301374 - hummingbot.strategy.script_strategy_base - INFO - Creating GAS-USDT sell order: price: 5.242989802747732885003081739 amount: 2.140563681769532643596146985.
      2024-04-19 02:31:12,592 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - INFO - Created maker order 93027a12dac34fBCSGSUT3276be44bd8 at price 5.242989802747732885003081739.
      2024-04-19 02:31:12,709 - 1301374 - hummingbot.connector.client_order_tracker - INFO - Created LIMIT SELL order 93027a12dac34fBCSGSUT3276be44bd8 for 2.140563 GAS-USDT.
      2024-04-19 02:31:12,709 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - INFO - Maker order 93027a12dac34fBCSGSUT3276be44bd8 created.
      2024-04-19 02:31:12,722 - 1301374 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1713493872.0, "type": "OrderType.LIMIT", "trading_pair": "GAS-USDT", "amount": "2.140563", "price": "5.242", "order_id": "93027a12dac34fBCSGSUT3276be44bd8", "creation_timestamp": 1713493872.0, "exchange_order_id": "701379369264480257", "leverage": 1, "position": "NIL", "event_name": "SellOrderCreatedEvent", "event_source": "okx"}
      2024-04-19 02:31:13,466 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:13,467 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:14,473 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:14,474 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:15,471 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:15,472 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:16,474 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:16,475 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:17,476 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:17,477 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:18,480 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:18,481 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:19,481 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:19,482 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:20,485 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:20,485 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      2024-04-19 02:31:21,487 - 1301374 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
      
      • Part of the logs above, observed that it did not created a buy order when maker has enough to balance
      • Taker exchange had insufficient base assets that cause this behavior

04192024.zip

Copy link
Contributor

@rapcmia rapcmia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Setup controller config generic.xemm_multiple_levels.py
  • Ran tests on Kucoin, Okx and Binance spot connectors
  • Maker connector create limit order, taker connector create market order
  • When Maker and Taker orders are completed, executor terminated
  • When target profitability is below min_profitability, order is canceled
  • When target profitability is above max_profitability, order is canceled
  • When target profitability is between min and max, order stays active ✅
  • Ran long term bots and observe behavior
    • User must always check inventory, when not enough balance script would return "Not enough budget to open position"
    • When the target profitability rate is tight, connector tends to create and cancel order after 5-10s resulting large log files
    • Trade data between CSV, history and exchange trade history match
    • Multiple order levels are supported
    • Observe partial fills on tests and works ok on script
  • Build docker image ok

@rapcmia
Copy link
Contributor

rapcmia commented Apr 19, 2024

Failing tests in test_get_custom_info (test.hummingbot.smart_components.executors.dca_executor.test_dca_executor.TestDCAExecutor)

image

@rapcmia rapcmia merged commit 5d61b6c into hummingbot:development Apr 22, 2024
2 checks passed
@rapcmia
Copy link
Contributor

rapcmia commented Apr 22, 2024

Merged to development and part of release version 1.27.0

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.

None yet

2 participants