HKUDS/Vibe-Trading · error · LongbridgeConfigError
Longbridge SDK has no method '{name}'
Error message
Longbridge SDK has no method '{name}' What it means
Raised by the internal _call helper when reflecting a method name off the Longbridge SDK client object and it doesn't exist. This happens when the installed longport/longbridge Python package version doesn't match the method names the connector expects (e.g. after an SDK upgrade/renaming or a very old SDK).
Source
Thrown at agent/src/trading/connectors/longbridge/sdk.py:912
}
def _bar_to_dict(item: Any) -> dict[str, Any]:
return {
"time": str(_first(item, ("timestamp",), "")),
"open": _float_or_none(_first(item, ("open",))),
"high": _float_or_none(_first(item, ("high",))),
"low": _float_or_none(_first(item, ("low",))),
"close": _float_or_none(_first(item, ("close",))),
"volume": _float_or_none(_first(item, ("volume",))),
"turnover": _float_or_none(_first(item, ("turnover",))),
}
def _call(obj: Any, name: str, *args: Any, **kwargs: Any) -> Any:
fn = getattr(obj, name, None)
if fn is None:
raise LongbridgeConfigError(f"Longbridge SDK has no method '{name}'")
return fn(*args, **kwargs)
def _safe_call(obj: Any, name: str, *args: Any) -> Any:
fn = getattr(obj, name, None)
if fn is None:
return None
try:
return fn(*args)
except Exception: # noqa: BLE001 - optional read, degrade quietly
return None
View on GitHub (pinned to 80ffdda44c)
Solutions
- Check the installed version: pip show longport (or longbridge) and compare with the version the connector supports
- Upgrade the SDK: pip install -U longport
- Pin a known-good version in requirements (e.g. longport==x.y.z) matching the connector's expected API
- If the method was renamed, update the connector wrapper in agent/src/trading/connectors/longbridge/sdk.py to call the new name
Example fix
# before pip install longport==0.1.0 # old, missing methods # after pip install -U 'longport>=3.0'
Defensive patterns
Strategy: validation
Validate before calling
import importlib
def longbridge_sdk_ok(methods=("balance", "stock_quote")):
try:
import longport
except ImportError:
return False
return True
# after client construction:
# assert all(hasattr(client, m) for m in methods) Try / catch
try:
snap = get_account_snapshot()
except LongbridgeConfigError as e:
if 'no method' in str(e):
raise RuntimeError(f'SDK/connector version mismatch: {e} — upgrade longport') from e
raise Prevention
- Pin the longport SDK version in requirements
- Run a startup smoke check that hasattr()s the methods the connector uses
- Test after any SDK upgrade before enabling trading
When it happens
Trigger: Calling get_account_snapshot, get_positions, get_open_orders, get_quote or get_quotes through the connector when the wrapped Longbridge SDK object lacks the method name the connector looks up via getattr.
Common situations: Upgraded or downgraded the longport SDK so trade/quote API methods were renamed; using an exotic fork of the SDK; connector code written against a newer SDK than installed.
Related errors
- unknown universe {universe!r}; expected one of {sorted(_VALI
- unknown zoo {v!r}; expected one of {sorted(_VALID_ZOOS)}
- unknown universe {v!r}; expected one of {sorted(_BENCH_UNIVE
- invalid alpha_id {aid!r}
- need at least 2 distinct alpha_ids to compare
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/89f658393b989da4.
Report an issue: GitHub.