{"record":{"id":"81c3c65910eeddfc","repo":"QuantConnect/Lean","slug":"please-overrride-the-select-fundamental-function","errorCode":null,"errorMessage":"Please overrride the 'select' fundamental function","messagePattern":"Please overrride the 'select' fundamental function","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.py","lineNumber":95,"sourceCode":"            coarse: The coarse fundamental data used to perform filtering\n        Returns:\n            An enumerable of symbols passing the filter'''\n        if self.filter_fine_data:\n            fundamental = filter(lambda c: c.has_fundamental_data, fundamental)\n        if hasattr(self, \"SelectCoarse\") and callable(self.SelectCoarse):\n            # handle both 'select_coarse' and 'SelectCoarse' for backwards compatibility\n            return self.SelectCoarse(algorithm, fundamental)\n        return self.select_coarse(algorithm, fundamental)\n\n\n    def select(self, algorithm: QCAlgorithm, fundamental: list[Fundamental]) -> list[Symbol]:\n        '''Defines the fundamental selection function.\n        Args:\n            algorithm: The algorithm instance\n            fundamental: The fundamental data used to perform filtering\n        Returns:\n            An enumerable of symbols passing the filter'''\n        raise NotImplementedError(\"Please overrride the 'select' fundamental function\")\n\n\n    def select_coarse(self, algorithm: QCAlgorithm, fundamental: list[Fundamental]) -> list[Symbol]:\n        '''Defines the coarse fundamental selection function.\n        Args:\n            algorithm: The algorithm instance\n            coarse: The coarse fundamental data used to perform filtering\n        Returns:\n            An enumerable of symbols passing the filter'''\n        raise NotImplementedError(\"Please overrride the 'select' fundamental function\")\n\n\n    def select_fine(self, algorithm: QCAlgorithm, fundamental: list[Fundamental]) -> list[Symbol]:\n        '''Defines the fine fundamental selection function.\n        Args:\n            algorithm: The algorithm instance\n            fine: The fine fundamental data used to perform filtering\n        Returns:","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.py#L77-L113","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Override select(self, algorithm, fundamental) in your subclass to return list[Symbol] (or the older Select name for back-compat).","If you intended the coarse→fine path instead, configure the model for coarse+fine (fundamental_data false) and override select_coarse."],"exampleFix":"# before\nclass MyUniverse(FundamentalUniverseSelectionModel):\n    def __init__(self):\n        super().__init__(fundamental_data=True)\n    # no select() -> raises NotImplementedError\n\n# after\nclass MyUniverse(FundamentalUniverseSelectionModel):\n    def __init__(self):\n        super().__init__(fundamental_data=True)\n    def select(self, algorithm, fundamental):\n        return [f.symbol for f in fundamental if f.market_cap > 1e9]","handlingStrategy":"type-guard","validationCode":"# Verify at construction that select is overridden on the fundamental path\nclass MyUniverse(FundamentalUniverseSelectionModel):\n    def __init__(self):\n        super().__init__(fundamental_data=True)\n    def select(self, algorithm, fundamental):\n        return [f.symbol for f in fundamental if f.has_fundamental_data]","typeGuard":"def select_is_overridden(model) -> bool:\n    return type(model).select is not FundamentalUniverseSelectionModel.select","tryCatchPattern":null,"preventionTips":["Match the selection hook to the path: fundamental_data=True needs select(); False needs select_coarse().","Unit-test a fresh subclass by calling select()/select_coarse() once with a tiny sample to confirm it doesn't raise NotImplementedError."],"tags":["universe-selection","fundamentals","not-implemented","subclassing"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}