{"record":{"id":"3743c7262fb741ad","repo":"HKUDS/Vibe-Trading","slug":"factor-panel-and-forward-returns-must-be-non-empty","errorCode":null,"errorMessage":"factor_panel and forward_returns must be non-empty","messagePattern":"factor_panel and forward_returns must be non-empty","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/factormodel.py","lineNumber":778,"sourceCode":"\n    Args:\n        factor_panel: DataFrame of factor scores (index = dates, columns = assets).\n        forward_returns: DataFrame of forward returns (same shape and alignment; should be pre-shifted by caller).\n        method: Correlation method, ``'spearman'`` (Rank IC) or ``'pearson'`` (Linear IC).\n        min_cross_section: Minimum number of valid assets on a date to compute IC.\n\n    Returns:\n        :class:`FactorICResult` containing mean IC, IC IR, t-statistic, p-value,\n        higher moments, and full IC time series.\n\n    Raises:\n        ValueError: If inputs are empty, share no common dates or assets, or method is unknown.\n    \"\"\"\n    if method not in (\"spearman\", \"pearson\"):\n        raise ValueError(f\"method must be 'spearman' or 'pearson', got {method!r}\")\n\n    if factor_panel.empty or forward_returns.empty:\n        raise ValueError(\"factor_panel and forward_returns must be non-empty\")\n\n    # Align dates and assets\n    common_dates = factor_panel.index.intersection(forward_returns.index)\n    common_assets = factor_panel.columns.intersection(forward_returns.columns)\n\n    if common_dates.empty or common_assets.empty:\n        raise ValueError(\"No common dates and assets between factor_panel and forward_returns\")\n\n    f_sub = factor_panel.loc[common_dates, common_assets]\n    r_sub = forward_returns.loc[common_dates, common_assets]\n\n    ic_records: dict[object, float] = {}\n\n    for date in common_dates:\n        f_row = f_sub.loc[date].dropna()\n        r_row = r_sub.loc[date].dropna()\n        shared = f_row.index.intersection(r_row.index)\n        if len(shared) < min_cross_section:","sourceCodeStart":760,"sourceCodeEnd":796,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/factormodel.py#L760-L796","documentation":"Both factor_panel and forward_returns must be non-empty DataFrames (dates x assets); an empty input leaves no cross-sections to correlate so the function bails out early.","triggerScenarios":"factor_panel=pd.DataFrame() or forward_returns sliced to zero rows by a date filter.","commonSituations":"Empty date-range query upstream; data pull failed silently and returned an empty frame; over-aggressive dropna removed everything.","solutions":["Check .empty on both frames before calling","Verify the upstream date/asset query actually returned data","Log shapes of both panels at ingest time"],"exampleFix":"# before\nic = factor_ic_analysis(panel, rets)\n# after\nic = factor_ic_analysis(panel, rets) if not (panel.empty or rets.empty) else None","handlingStrategy":"validation","validationCode":"assert not factor_panel.empty and not forward_returns.empty","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail loudly on empty data pulls upstream","Log panel shapes at ingest"],"tags":["quantlib","factormodel","empty-input","ic-analysis"],"backgroundTag":"empty-input-validation","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}