{"record":{"id":"0e1c38437a394cfc","repo":"HKUDS/Vibe-Trading","slug":"need-at-least-2-distinct-alpha-ids-to-compare","errorCode":null,"errorMessage":"need at least 2 distinct alpha_ids to compare","messagePattern":"need at least 2 distinct alpha_ids to compare","errorType":"validation","errorClass":"ValueError","httpStatus":422,"severity":"error","filePath":"agent/src/api/alpha_routes.py","lineNumber":200,"sourceCode":"    alpha_ids: list[str] = Field(..., min_length=2, max_length=50)\n    universe: str = Field(..., min_length=1, max_length=64)\n    period: str = Field(..., min_length=4, max_length=32)\n    sort: str = Field(\"ir\", min_length=1, max_length=32)\n\n    @field_validator(\"alpha_ids\")\n    @classmethod\n    def _ids_well_formed(cls, v: list[str]) -> list[str]:\n        # De-duplicate (preserve order) and validate each id shape.\n        seen: set[str] = set()\n        out: list[str] = []\n        for aid in v:\n            if not _ALPHA_ID_RE.fullmatch(aid or \"\"):\n                raise ValueError(f\"invalid alpha_id {aid!r}\")\n            if aid not in seen:\n                seen.add(aid)\n                out.append(aid)\n        if len(out) < 2:\n            raise ValueError(\"need at least 2 distinct alpha_ids to compare\")\n        return out\n\n    @field_validator(\"universe\")\n    @classmethod\n    def _universe_known(cls, v: str) -> str:\n        if v not in _BENCH_UNIVERSES:\n            raise ValueError(\n                f\"unknown universe {v!r}; expected one of {sorted(_BENCH_UNIVERSES)}\"\n            )\n        return v\n\n    @field_validator(\"sort\")\n    @classmethod\n    def _sort_known(cls, v: str) -> str:\n        if v not in _VALID_SORTS:\n            raise ValueError(f\"unknown sort {v!r}; expected one of {sorted(_VALID_SORTS)}\")\n        return v\n","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/alpha_routes.py#L182-L218","documentation":"Scaffold stub for get_positions in plugin_scaffold.py. It raises NotImplementedError until the developer implements it to call the broker's positions endpoint and return {'positions': [...]}. Runtime occurrence means an installed connector still has the template stub.","triggerScenarios":"Calling get_positions (directly or via the trading service) on a scaffolded-but-unimplemented local connector; the stub raises because it contains no broker logic.","commonSituations":"Testing discovery/install flow with a stock scaffold; implemented account snapshot but left positions as the stub; copied an old scaffold missing the newer contract.","solutions":["Implement get_positions to call the broker positions API and return {\"positions\": [ ... normalized position dicts ... ]}","Reinstall/refresh the installed plugin copy after editing","Do not select this profile for position reads until implemented"],"exampleFix":"# before\ndef get_positions(*, credentials, config):\n    raise NotImplementedError(\"Call the broker positions endpoint...\")\n\n# after\ndef get_positions(*, credentials, config):\n    resp = broker_client(credentials).list_positions()\n    return {\"positions\": [\n        {\"symbol\": p[\"symbol\"], \"qty\": float(p[\"qty\"]), \"market_value\": float(p[\"market_value\"])}\n        for p in resp\n    ]}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def positions_implemented(adapter) -> bool:\n    import inspect\n    fn = getattr(adapter, \"get_positions\", None)\n    return callable(fn) and \"NotImplementedError\" not in inspect.getsource(fn)","tryCatchPattern":"try:\n    result = _local_plugin_call(profile, \"get_positions\", overrides)\nexcept NotImplementedError:\n    return {\"positions\": [], \"unavailable\": True}  # graceful degrade","preventionTips":["Fill in all scaffold stubs before running install_connector","Smoke-test each operation once after implementing","Grep the adapter for 'NotImplementedError' as a pre-install check"],"tags":["scaffold","not-implemented","local-connector","trading"],"backgroundTag":"notimplementederror-stub","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}