{"record":{"id":"3c630988fef64cb6","repo":"HKUDS/Vibe-Trading","slug":"market-caps-is-missing-len-missing-asset-s-pre","errorCode":null,"errorMessage":"market_caps is missing {len(missing)} asset(s) present in values","messagePattern":"market_caps is missing (.+?) asset\\(s\\) present in values","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/factormodel.py","lineNumber":290,"sourceCode":"    if finite.size < MIN_CROSS_SECTION:\n        raise ValueError(\n            f\"a cross-section needs at least {MIN_CROSS_SECTION} finite values to \"\n            f\"standardise, got {finite.size}\"\n        )\n\n    if winsorise > 0:\n        lower, upper = finite.quantile(winsorise), finite.quantile(1.0 - winsorise)\n        clipped = series.clip(lower=lower, upper=upper)\n    else:\n        clipped = series\n\n    if market_caps is None:\n        centre = float(clipped.dropna().mean())\n    else:\n        caps = pd.Series(market_caps, dtype=float)\n        missing = series.index.difference(caps.index)\n        if len(missing):\n            raise ValueError(\n                f\"market_caps is missing {len(missing)} asset(s) present in values\"\n            )\n        aligned_caps = caps.reindex(clipped.index)\n        usable = clipped.notna() & aligned_caps.notna() & (aligned_caps > 0)\n        if not usable.any():\n            raise ValueError(\"no asset has both a finite value and a positive market cap\")\n        weights = aligned_caps[usable]\n        centre = float((clipped[usable] * weights).sum() / weights.sum())\n\n    spread = float(clipped.dropna().std(ddof=1))\n    if not np.isfinite(spread) or spread <= 0.0:\n        raise ValueError(\n            \"the characteristic has no cross-sectional variation, so a z-score \"\n            \"would divide by zero\"\n        )\n    return (clipped - centre) / spread\n\n","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/factormodel.py#L272-L308","documentation":"When market_caps is supplied for cap-weighted centring, standardise_exposures requires caps for every asset present in values; missing tickers would force a silent fallback or NaN centre, so the mismatch is raised up front.","triggerScenarios":"Passing a market_caps Series whose index lacks some tickers present in the characteristic values — e.g. caps snapshot taken on a different date or from a different vendor with ticker-naming differences.","commonSituations":"Ticker convention mismatches (BRK.B vs BRK-B), caps file lagging the universe file, or new listings not yet in the caps data.","solutions":["Reindex/merge caps onto the values index: caps = caps.reindex(values.index) and investigate the NaNs.","Fix ticker normalisation so both sides use the same symbols; drop assets without caps from values if cap-weighting must proceed."],"exampleFix":"# before\nz = standardise_exposures(values, market_caps=caps)\n# after\nmissing = values.index.difference(caps.index)\nz = standardise_exposures(values.drop(index=missing), market_caps=caps)","handlingStrategy":"validation","validationCode":"missing = values.index.difference(market_caps.index)\nassert not len(missing), missing[:5]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalise ticker symbols across caps and characteristic files.","Snapshot caps on the same calendar as the universe."],"tags":["factormodel","pandas","index-alignment"],"backgroundTag":"index-misalignment","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}