Skip to content

fix(rates): repoint rate_finder to renamed hummingbot token normalizer - #192

Merged
rapcmia merged 1 commit into
mainfrom
fix/rate-finder-gateway-utils-import
Jul 13, 2026
Merged

fix(rates): repoint rate_finder to renamed hummingbot token normalizer#192
rapcmia merged 1 commit into
mainfrom
fix/rate-finder-gateway-utils-import

Conversation

@fengtality

Copy link
Copy Markdown
Contributor

Fixes #191

Problem

HAPI fails at startup with ModuleNotFoundError: No module named 'hummingbot.core.gateway.utils' when built against hummingbot development newer than June 28. Hummingbot commit a71a92a5 deleted hummingbot/core/gateway/utils.py and renamed the helper unwrap_token_symbolnormalize_token_symbol, relocating it to hummingbot.core.rate_oracle.utils. utils/rate_finder.py (introduced in f067c37) still imported from the deleted path, killing the whole app import chain (main.py → routers → deps → services → rate_finder).

Changes

  1. Import fix: rate_finder.py now imports normalize_token_symbol from hummingbot.core.rate_oracle.utils (its new name and location).
  2. Latent rate-resolution bug found during validation: the find_rate port never re-checked the direct pair after USD→USDT normalization, so e.g. HBOT-USD returned None even with HBOT-USDT present in the ticker pool. Added the normalized-pair re-check to match upstream hummingbot's find_rate.

Compatibility note for QA

This PR requires a hummingbot wheel built from development at/after a71a92a5 (the module rename). It will not import against older wheels (e.g. 20260515), which only have the old unwrap_token_symbol path — pair this with a current dev wheel when testing.

⚠️ Wheel-build gotcha that masked this bug: setuptools' incremental build/lib never propagates source-file deletions, so wheels rebuilt from an existing hummingbot checkout silently re-include the deleted core/gateway/utils.py (and three stale hummingbot/cli/ files). If a rebuilt wheel still "works" with the old import, check unzip -l dist/hummingbot-*.whl | grep gateway/utils and purge stale files from build/lib.* (or delete the build dir) before building.

Testing

  • Reproduced the exact ModuleNotFoundError from the issue by importing rate_finder against post-a71a92a5 hummingbot source.
  • After the fix, with a clean-built current dev wheel installed:
    • main.py (the uvicorn entrypoint) imports cleanly end-to-end.
    • 9-case find_rate matrix passes: direct, direct-after-normalization (HBOT-USD), reverse, reverse-after-normalization, both cross-rate bridging paths, identity after normalization (USD-USDT → 1), and no-path → None.
  • Swept every from hummingbot... import across routers/services/utils/models against the new layout — hummingbot.core.gateway.utils was the only break.

🤖 Generated with Claude Code

Hummingbot commit a71a92a5 deleted hummingbot/core/gateway/utils.py and renamed
unwrap_token_symbol -> normalize_token_symbol in hummingbot.core.rate_oracle.utils,
so HAPI failed at startup with ModuleNotFoundError when built against hummingbot
dev newer than June 28. Import the helper from its new location.

Also fix a latent bug in the find_rate port: after normalizing USD -> USDT it
never re-checked the direct normalized pair, so e.g. HBOT-USD returned None even
with HBOT-USDT in the ticker pool. Add the re-check to match upstream find_rate.

Fixes #191

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rapcmia

rapcmia commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
  • I tested the running Docker HAPI build through /market-data/rates and the rate lookup behaved the way a user would expect across the main paths: direct pairs worked, inverse pairs worked, USD-to-USDT normalization worked.
  • On Hyperliquid spot, I checked the real trading flow using HYPE-USDC and the reverse USDC-HYPE, and both prices resolved correctly.
  • On Hyperliquid perpetual, I checked the real pair shape HYPE-USD, and that price also resolved correctly.
  • This Docker setup is using the dev-built wheel path the PR expects, so the environment I tested matches the intended dependency line for this change.
  • I also tested this against the current Hummingbot lib, and it still ok

@rapcmia
rapcmia merged commit ddcc11e into main Jul 13, 2026
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.

HAPI - Fails to start with ModuleNotFoundError for hummingbot.core.gateway.utils

2 participants