{"record":{"id":"89f658393b989da4","repo":"HKUDS/Vibe-Trading","slug":"longbridge-sdk-has-no-method-name","errorCode":null,"errorMessage":"Longbridge SDK has no method '{name}'","messagePattern":"Longbridge SDK has no method '(.+?)'","errorType":"exception","errorClass":"LongbridgeConfigError","httpStatus":null,"severity":"error","filePath":"agent/src/trading/connectors/longbridge/sdk.py","lineNumber":912,"sourceCode":"    }\n\n\ndef _bar_to_dict(item: Any) -> dict[str, Any]:\n    return {\n        \"time\": str(_first(item, (\"timestamp\",), \"\")),\n        \"open\": _float_or_none(_first(item, (\"open\",))),\n        \"high\": _float_or_none(_first(item, (\"high\",))),\n        \"low\": _float_or_none(_first(item, (\"low\",))),\n        \"close\": _float_or_none(_first(item, (\"close\",))),\n        \"volume\": _float_or_none(_first(item, (\"volume\",))),\n        \"turnover\": _float_or_none(_first(item, (\"turnover\",))),\n    }\n\n\ndef _call(obj: Any, name: str, *args: Any, **kwargs: Any) -> Any:\n    fn = getattr(obj, name, None)\n    if fn is None:\n        raise LongbridgeConfigError(f\"Longbridge SDK has no method '{name}'\")\n    return fn(*args, **kwargs)\n\n\ndef _safe_call(obj: Any, name: str, *args: Any) -> Any:\n    fn = getattr(obj, name, None)\n    if fn is None:\n        return None\n    try:\n        return fn(*args)\n    except Exception:  # noqa: BLE001 - optional read, degrade quietly\n        return None\n","sourceCodeStart":894,"sourceCodeEnd":924,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/trading/connectors/longbridge/sdk.py#L894-L924","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\npip install longport==0.1.0  # old, missing methods\n# after\npip install -U 'longport>=3.0'","handlingStrategy":"validation","validationCode":"import importlib\ndef longbridge_sdk_ok(methods=(\"balance\", \"stock_quote\")):\n    try:\n        import longport\n    except ImportError:\n        return False\n    return True\n# after client construction:\n# assert all(hasattr(client, m) for m in methods)","typeGuard":null,"tryCatchPattern":"try:\n    snap = get_account_snapshot()\nexcept LongbridgeConfigError as e:\n    if 'no method' in str(e):\n        raise RuntimeError(f'SDK/connector version mismatch: {e} — upgrade longport') from e\n    raise","preventionTips":["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"],"tags":["longbridge","sdk","version-mismatch","getattr","trading"],"backgroundTag":"sdk-method-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}