Skip to content

fix: initialize active order timestamps in api trading flows#143

Open
marcuspocus wants to merge 591 commits into
hummingbot:developmentfrom
marcuspocus:fix/active-orders-nan-timestamps
Open

fix: initialize active order timestamps in api trading flows#143
marcuspocus wants to merge 591 commits into
hummingbot:developmentfrom
marcuspocus:fix/active-orders-nan-timestamps

Conversation

@marcuspocus
Copy link
Copy Markdown

Summary

Fix active order timestamp handling for API-managed connectors that are not running under a Hummingbot Clock.

This change does two things:

  • initializes the connector timestamp before buy / sell calls in the API trading flows
  • makes /trading/orders/active tolerate non-finite timestamps if they still appear on an in-flight order

Context

While validating Hyperliquid perpetual testnet order placement through hummingbot-api, the exchange-side order flow was working, but /trading/orders/active could fail when it tried to serialize a freshly created in-flight order.

The root cause is that API-managed connectors in this stack are not driven by a persistent Hummingbot Clock. In that setup, connector.current_timestamp can still be NaN at order creation time. Since ExchangePyBase.start_tracking_order() copies self.current_timestamp into the new InFlightOrder, the order may be tracked with creation_timestamp = NaN and last_update_timestamp = NaN until the first update arrives.

That makes the active-orders serializer fragile because it attempts to convert those values to datetimes.

Changes

  • call connector._set_current_timestamp(time.time()) before delegating to connector.buy() / connector.sell() in:
    • services/accounts_service.py
    • services/trading_service.py
    • AccountsService.place_trade(...)
  • harden _standardize_in_flight_order_response() so non-finite timestamps are returned as None instead of raising during serialization
  • add focused tests that cover:
    • timestamp initialization before order submission
    • active-order serialization when timestamps are NaN

Validation

Targeted tests:

  • /root/hummingbot-stack/.venv-pr/bin/python -m pytest -q test/test_order_timestamp_tracking.py test/test_trading_router.py
  • result: 6 passed

Manual validation against a local hummingbot-api deployment:

  • submitted a BUY LIMIT BTC-USD order on hyperliquid_perpetual_testnet
  • confirmed /trading/orders/active returned 200 with the live order present
  • confirmed the order could be canceled successfully

Notes

This PR stays narrow:

  • no connector logic changes
  • no exchange-specific workaround
  • no change to historical order storage
  • only the API-side handling needed to keep active-order tracking consistent for API-managed connectors

david-hummingbot and others added 30 commits September 13, 2025 06:49
…t_api_to_library

(feat) adapt connector initialization
Adding multi_grid_strike.py so I can use it with hummingbot-mcp
- matching PR for #7796
cardosofede and others added 28 commits February 18, 2026 15:29
Resolved conflict in services/executor_service.py by keeping ExecutorLogCapture import
- Handle LP executor's market structure in executor_service (extracts
  connector_name/trading_pair from market object instead of direct fields)
- Add LP executor example to CreateExecutorRequest schema
- Add LP-specific types: LP_EXECUTOR_STATES, LP_EXECUTOR_SIDES,
  ConnectorPairConfig, LPExecutorConfigSchema, LPExecutorCustomInfo
- Update router docstrings with LP executor configuration details
- Update /types/available endpoint with better LP executor description

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Adds the LP Rebalancer controller for automated LP position management:
- Uses total_amount_quote and side for position sizing
- Implements KEEP vs REBALANCE logic based on price limits
- Supports directional grids with sell/buy price ranges
- Auto-rebalances when price moves out of range beyond threshold

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Update list_controllers to detect both single-file and package-style controllers
- Update get_controller to read from both locations
- Update create/update controller to write to existing package or create single file
- Update delete controller to handle both file and folder deletion
- Update load_controller_config_class to try both import paths
- Fix lp_rebalancer __init__.py to use relative import
- Remove stale lp_manager.py (replaced by lp_rebalancer)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Remove LP-specific types from models/executors.py (duplicates of hummingbot types)
- Update LPExecutorConfig to use direct connector_name/trading_pair fields
- Simplify executor_service.py by removing LP-specific handling
- Sync lp_rebalancer controller with hummingbot version

This aligns LP executor with the pattern used by position, grid, and DCA
executors, making the API consistent across all executor types.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add DEVELOPERS.md with detailed instructions for:
  - Building hummingbot wheel from custom branches
  - Building Linux wheels for Docker using containerized builds
  - Setting up development environment with custom wheels
  - Troubleshooting common issues (platform mismatch, Python version)
- Add environment.docker.yml for Docker builds with local wheel
- Add environment.yml.example as template for developers
- Update Dockerfile to support custom wheel builds
- Add *.whl to .gitignore for local development

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Revert Dockerfile to original (uses PyPI hummingbot)
- Add Dockerfile.dev for development builds with custom wheel
- Update DEVELOPERS.md to use Dockerfile.dev for custom builds

This keeps the main CI/CD pipeline unchanged while enabling
developers to test with custom hummingbot branches.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add docker-compose.dev.yml that uses hummingbot-api:dev image
- Update DEVELOPERS.md with simplified deployment instructions
- Enables testing with custom hummingbot branches

Tested: lp_executor now shows in available executor types when
using development hummingbot wheel.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Document how to deploy bots using development hummingbot images
instead of the default :latest tag.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add gateway_proxy router (prefix: /gateway-proxy) that forwards requests to Gateway
- Fix DELETE requests not forwarding body to Gateway
- Keep executors router and lp_executor services from feat/lp-executor
- Resolve all merge conflicts in main.py imports and router registration
- Fix flake8: blank lines, unused imports, long lines
- Add GatewayLp support in unified_connector_service for gateway connectors
  (meteora/clmm, raydium/clmm, etc.) that aren't in AllConnectorSettings
- Remove candles_config and markets from v2_with_controllers script config
  to fix compatibility with hummingbot:staging branch
- Remove development Docker files (moved to separate workflow)
- Fix f-strings without placeholders

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Test GatewayLp import, instantiation, and required methods
- Test gateway detection logic in _create_trading_connector
- Test script config fix (candles_config/markets removed)
- Test LP executor type registration
- Integration tests for API endpoints

Verifies fixes for:
- KeyError: 'meteora/clmm' issue
- Staging deployment compatibility

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Closes hummingbot#133 - Prevents recurring "Invalid Ethereum address format" errors
by skipping wallets with placeholder values like "ethereum-default-wallet"
or "solana-default-wallet" during balance polling.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Added a function to pull the latest Hummingbot Docker image during setup.
Add function to pull Hummingbot Docker image
@marcuspocus marcuspocus marked this pull request as ready for review April 6, 2026 16:30
@marcuspocus marcuspocus changed the base branch from main to development April 13, 2026 11:16
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.

6 participants