QuantConnect/Lean · error · NotImplementedError

Please overrride the 'select' fundamental function

Error message

Please overrride the 'select' fundamental function

What it means

FundamentalUniverseSelectionModel.select() is the single-pass fundamental selection hook. The base implementation raises NotImplementedError to force subclasses to override it; if a subclass uses the fundamental-data (single-pass) path but doesn't implement select(), Lean calls the base method and fails.

Source

Thrown at Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.py:95

            coarse: The coarse fundamental data used to perform filtering
        Returns:
            An enumerable of symbols passing the filter'''
        if self.filter_fine_data:
            fundamental = filter(lambda c: c.has_fundamental_data, fundamental)
        if hasattr(self, "SelectCoarse") and callable(self.SelectCoarse):
            # handle both 'select_coarse' and 'SelectCoarse' for backwards compatibility
            return self.SelectCoarse(algorithm, fundamental)
        return self.select_coarse(algorithm, fundamental)


    def select(self, algorithm: QCAlgorithm, fundamental: list[Fundamental]) -> list[Symbol]:
        '''Defines the fundamental selection function.
        Args:
            algorithm: The algorithm instance
            fundamental: The fundamental data used to perform filtering
        Returns:
            An enumerable of symbols passing the filter'''
        raise NotImplementedError("Please overrride the 'select' fundamental function")


    def select_coarse(self, algorithm: QCAlgorithm, fundamental: list[Fundamental]) -> list[Symbol]:
        '''Defines the coarse fundamental selection function.
        Args:
            algorithm: The algorithm instance
            coarse: The coarse fundamental data used to perform filtering
        Returns:
            An enumerable of symbols passing the filter'''
        raise NotImplementedError("Please overrride the 'select' fundamental function")


    def select_fine(self, algorithm: QCAlgorithm, fundamental: list[Fundamental]) -> list[Symbol]:
        '''Defines the fine fundamental selection function.
        Args:
            algorithm: The algorithm instance
            fine: The fine fundamental data used to perform filtering
        Returns:

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Override select(self, algorithm, fundamental) in your subclass to return list[Symbol] (or the older Select name for back-compat).
  2. If you intended the coarse→fine path instead, configure the model for coarse+fine (fundamental_data false) and override select_coarse.

Example fix

# before
class MyUniverse(FundamentalUniverseSelectionModel):
    def __init__(self):
        super().__init__(fundamental_data=True)
    # no select() -> raises NotImplementedError

# after
class MyUniverse(FundamentalUniverseSelectionModel):
    def __init__(self):
        super().__init__(fundamental_data=True)
    def select(self, algorithm, fundamental):
        return [f.symbol for f in fundamental if f.market_cap > 1e9]
Defensive patterns

Strategy: type-guard

Validate before calling

# Verify at construction that select is overridden on the fundamental path
class MyUniverse(FundamentalUniverseSelectionModel):
    def __init__(self):
        super().__init__(fundamental_data=True)
    def select(self, algorithm, fundamental):
        return [f.symbol for f in fundamental if f.has_fundamental_data]

Type guard

def select_is_overridden(model) -> bool:
    return type(model).select is not FundamentalUniverseSelectionModel.select

Prevention

When it happens

Trigger: A FundamentalUniverseSelectionModel subclass is instantiated with fundamental_data enabled (so create_universes() routes through the FundamentalUniverseFactory path that calls self.select), but the subclass never defines select(algorithm, fundamental).

Common situations: Subclassing the model and only implementing select_coarse/select_fine (the two-stage path) while the instance is configured for the single-pass fundamental path; or forgetting to override the method entirely.

Related errors


AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13). Data as JSON: /api/errors/81c3c65910eeddfc. Report an issue: GitHub.