HKUDS/Vibe-Trading · warning · SkipAlpha

{alpha_id}: panel missing sector tag

Error message

{alpha_id}: panel missing sector tag

What it means

The alpha's metadata sets requires_sector=True but the panel dict has no 'sector' key. compute() raises SkipAlpha before importing the module, since sector-aware factors cannot run without sector tags.

Source

Thrown at agent/src/factors/registry.py:339

    def compute(self, alpha_id: str, panel: dict[str, pd.DataFrame]) -> pd.DataFrame:
        """Lazy-import the alpha module and run its ``compute(panel)``.

        Raises:
            KeyError: alpha_id unknown.
            SkipAlpha: required column / sector tag absent in panel.
            RegistryError: import/compute failed or output failed sanity checks.
        """
        alpha = self.get(alpha_id)
        meta = alpha.meta

        missing = [c for c in meta.get("columns_required", []) if c not in panel]
        if missing:
            raise SkipAlpha(f"{alpha_id}: panel missing required columns {missing}")
        missing_extra = [c for c in meta.get("extras_required", []) if c not in panel]
        if missing_extra:
            raise SkipAlpha(f"{alpha_id}: panel missing extras {missing_extra}")
        if meta.get("requires_sector") and "sector" not in panel:
            raise SkipAlpha(f"{alpha_id}: panel missing sector tag")

        try:
            module = self._load_module(alpha)
        except Exception as exc:  # noqa: BLE001 — isolate import failure
            raise RegistryError(f"{alpha_id}: import failed: {exc}") from exc

        compute_fn = getattr(module, "compute", None)
        if compute_fn is None:
            raise RegistryError(f"{alpha_id}: module has no compute() function")

        try:
            result = compute_fn(panel)
        except Exception as exc:  # noqa: BLE001 — isolate compute failure
            raise RegistryError(f"{alpha_id}: compute() raised: {exc}") from exc

        return self._validate_output(alpha_id, result, panel)

    def _load_module(self, alpha: Alpha) -> ModuleType:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Add panel['sector'] as a wide DataFrame aligned to the price index
  2. Use sector-agnostic alphas if you have no classification data
  3. Check meta['requires_sector'] upfront and filter your alpha list

Example fix

# before
out = registry.compute(sector_alpha_id, panel)
# after
panel['sector'] = sector_df  # same index/columns as close
out = registry.compute(sector_alpha_id, panel)
Defensive patterns

Strategy: validation

Validate before calling

if registry.get(alpha_id).meta.get('requires_sector') and 'sector' not in panel:
    skip(alpha_id)

Type guard

def sector_ready(meta: dict, panel: dict) -> bool:
    return not meta.get('requires_sector') or 'sector' in panel

Try / catch

try:
    out = registry.compute(aid, panel)
except SkipAlpha:
    continue

Prevention

When it happens

Trigger: compute(alpha_id, panel) on an industry/neutrality-style factor without providing panel['sector'] (a wide DataFrame of sector labels).

Common situations: Panels built from price-only data with no classification data joined in; forgetting that sector is passed as a panel key, not a constructor option.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/a01e743d69b3f512. Report an issue: GitHub.