Skip to content

Conversation

@cardosofede
Copy link
Contributor

@cardosofede cardosofede commented Jan 21, 2026

Summary

This PR introduces a major architectural refactoring to consolidate connector management and adds native executor support via the API.

Key Changes

New Services Architecture:

  • UnifiedConnectorService (replaces ConnectorManager and connector management from MarketDataProvider): Single source of truth for all connector instances.
    Manages two types of connectors:
    • Trading connectors: Authenticated, per-account, with order tracking
    • Data connectors: Non-authenticated, shared, for public market data
  • MarketDataService (replaces MarketDataFeedManager): Centralized market data access (candles, order books, prices) with automatic feed lifecycle
    management
  • TradingService: Centralized trading operations with AccountTradingInterface - a ScriptStrategyBase-compatible interface that executors can use
  • ExecutorService: Manages Hummingbot executors directly via API without Docker containers or full strategy setup

New API Endpoints:

  • /executors - Full CRUD for executor management (Position, Grid, DCA, TWAP, Arbitrage, XEMM, Order executors)
  • /rate-oracle - Rate oracle configuration and rate queries

New Features:

  • Position Hold tracking: Aggregates positions from executors stopped with keep_position=true, tracking buy/sell amounts, breakeven prices, and
    realized/unrealized PnL
  • Order book tracker registration: Proper management of order book trackers per trading pair with automatic cleanup
  • Executor persistence: Database storage of executor state and history

Removed:

  • services/market_data_feed_manager.py (replaced by MarketDataService)
  • utils/connector_manager.py (replaced by UnifiedConnectorService)

Testing Recommendations

  1. Connector Management
  • Create trading connectors for multiple accounts and verify isolation
  • Test get_best_connector_for_market() returns trading connector when available
  • Verify data connector sharing (same connector used across requests)
  • Test order book tracker registration and removal on trading pairs
  • Test connector restart/recovery scenarios
  1. Executor Service
  • Create each executor type: position_executor, grid_executor, dca_executor, twap_executor, arbitrage_executor, xemm_executor, order_executor
  • Test executor stop with keep_position=false (should close position)
  • Test executor stop with keep_position=true (should update PositionHold)
  • Verify executor status transitions (RUNNING → TERMINATED)
  • Test executor filtering by account, connector, trading pair, status
  • Verify database persistence of executor history
  1. Trading Service
  • Place buy/sell orders through the API
  • Test order cancellation
  • Verify PositionAction handling for perpetual connectors (OPEN/CLOSE)
  • Test AccountTradingInterface.connectors property returns correct connectors
  1. Market Data Service
  • Start candle feeds and verify data
  • Test order book access via /market-data/order-book
  • Verify feed cleanup after timeout period
  • Test price queries through rate oracle
  1. Rate Oracle
  • GET /rate-oracle/sources - list available sources
  • GET /rate-oracle/config - get current configuration
  • PUT /rate-oracle/config - update source/quote token
  • POST /rate-oracle/rates - query specific rates
  1. Integration/E2E Tests
  • Create executor → place orders → stop executor → verify position hold
  • Multiple accounts trading same market simultaneously
  • Service restart and state recovery (executors should reload from DB)
  • Error handling: invalid executor config, connector not found, insufficient balance

@rapcmia rapcmia self-requested a review January 21, 2026 14:20
@rapcmia
Copy link
Contributor

rapcmia commented Jan 23, 2026

Commit 57be279

  • Successfully build docker image
  • Tested using docker build
  • Successfully setup and localhost:8000 ✅

Portfolio endpoints using binance, kucoin and hyperliquid_perpetual

  • /portfolio/state (POST) ok
  • /portfolio/history (POST) ok
  • /portfolio/distribution (POST) ok
  • /portfolio/accounts-distribution (GET) ok

Trading endpoints using kucoin and hyperliquid_perpertual specifically HIP-3 pairs XYZ:AMZN-USD

  • /trading/orders (POST) ok
  • /trading/{account}/{connector}/orders/{id}/cancel (POST) ok
  • /trading/positions (POST) ok
  • /trading/orders/active (POST) ok
  • /trading/orders/search (POST) ❌
    • I tried to search starting from 00:00 UTC and still was not able to fetch all historical orders
    • Check DB orders table and did not find any orders recorded (tested with kucoin also)
    • Crosschecking this behavior on main branch, able to record orders ✅
      image
  • /trading/trades (POST) ❌
    • We completed 2 market orders from kucoin and hyperliquid_perpetual but non recorded on db
  • /trading/{account}/{connector}/position-mode (POST/GET) ok
  • /trading/{account}/{connector}/leverage (POST) ok
  • /trading/funding-payments in progress

Pending tests:

  • Test executor routes

Incase needed, here is test logs: 23012026.log

cardosofede and others added 3 commits January 23, 2026 15:44
- Add recover_positions_from_db() method to ExecutorService
- Load executors with POSITION_HOLD close type on startup
- Reconstruct _positions_held tracking from final state
- Add get_position_hold_executors() to ExecutorRepository

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rapcmia
Copy link
Contributor

rapcmia commented Jan 26, 2026

Commit fc6eaf6

/trading/orders/search (POST) ❌

  • Fixed, all orders are recorded to db along with status (active or inactive state)
    • trading/orders/search (POST) ✅
    • /trading/trades (POST) ✅

  • position_executor ✅
  • grid_executor ✅
    • Tested using hyperliquid_perpetual (HYPE-USD and XYZ:AMZN-USD)
    • Successfully started executor then search, check and summary ok
    • Stop then terminate ok
    • Orders and positions are successfully created on exchange. Matched the responses return by hummingbot-api via curl ok
  • order_executor
    • Test using hyperliquid_perpetual using (XYZ:AMZN-USD)
      • Successfully placed order on buy and sell side on LIMIT, LIMIT_MAKER with related price
      • position_action OPEN and CLOSE ok
      • All order_executors were stopped but the status remains “shutting down” even after waiting 1-2 minutes
      • Order executors remain stuck in shutting down with is_active:false and cannot be deleted with response of not found in completed list, indicating that it never transitioned to complete or terminated state after stop ❌
        image
        # /executors/BXwsK4sPDkxR5pTnxXA4J5nZcB8j2mxVm8gvQVJTT7z
        curl -s -u admin:admin -X DELETE http://localhost:8000/executors/BXwsK4sPDkxR5pTnxXA4J5nZcB8j2mxVm8gvQVJTT7z | jq
        {
          "detail": "Executor BXwsK4sPDkxR5pTnxXA4J5nZcB8j2mxVm8gvQVJTT7z not found in completed list"
        }
        
        • I relaunch hummingbot-api and tried to search for these affected executor_ids and responded empty, however when i check postgress->executor table, i see these executors are on RUNNING state
        • Steps to reproduce:
          • Place a successful order_executor order on preferred exchange then initiate a executor/{executor_id}/stop
          • Check status of the executor_id using GET /executors/{executor_id} or try DELETE /executors/{executor_id}

Test logs: 23012026.log

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.

3 participants