{"record":{"id":"749008c20549c9f4","repo":"microsoft/qlib","slug":"please-implement-the-add-count-all-method","errorCode":null,"errorMessage":"Please implement the `add_count_all` method","messagePattern":"Please implement the `add_count_all` method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/backtest/position.py","lineNumber":187,"sourceCode":"            If only_stock=False, the weight of each stock in total assets(stock + cash) will be returned\n\n        Returns\n        -------\n        Dict:\n            {stock_id : value weight of stock in the position}\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `get_stock_weight_dict` method\")\n\n    def add_count_all(self, bar: str) -> None:\n        \"\"\"\n        Will be called at the end of each bar on each level\n\n        Parameters\n        ----------\n        bar :\n            The level to be updated\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `add_count_all` method\")\n\n    def update_weight_all(self) -> None:\n        \"\"\"\n        Updating the position weight;\n\n        # TODO: this function is a little weird. The weight data in the position is in a wrong state after dealing order\n        # and before updating weight.\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `add_count_all` method\")\n\n    ST_CASH = \"cash\"\n    ST_NO = \"None\"  # String is more typehint friendly than None\n\n    def settle_start(self, settle_type: str) -> None:\n        \"\"\"\n        settlement start\n        It will act like start and commit a transaction\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/position.py#L169-L205","documentation":"Error \"Please implement the `add_count_all` method\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/backtest/position.py:187 when the guard condition fails: \"Please implement the `add_count_all` method\". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.","commonSituations":"See trigger scenarios.","solutions":["Implement the `add_count_all` method in your Position subclass before calling it.","Use the built-in Position class which already implements `add_count_all`."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}