{"record":{"id":"b7897a3a8d3f626b","repo":"microsoft/qlib","slug":"please-implement-the-settle-conf-method","errorCode":null,"errorMessage":"Please implement the `settle_conf` method","messagePattern":"Please implement the `settle_conf` method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/backtest/position.py","lineNumber":216,"sourceCode":"    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\n        Parameters\n        ----------\n        settle_type : str\n            Should we make delay the settlement in each execution (each execution will make the executor a step forward)\n            - \"cash\": make the cash settlement delayed.\n                - The cash you get can't be used in current step (e.g. you can't sell a stock to get cash to buy another\n                        stock)\n            - None: not settlement mechanism\n            - TODO: other assets will be supported in the future.\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `settle_conf` method\")\n\n    def settle_commit(self) -> None:\n        \"\"\"\n        settlement commit\n        \"\"\"\n        raise NotImplementedError(f\"Please implement the `settle_commit` method\")\n\n    def __str__(self) -> str:\n        return self.__dict__.__str__()\n\n    def __repr__(self) -> str:\n        return self.__dict__.__repr__()\n\n\nclass Position(BasePosition):\n    \"\"\"Position\n\n    current state of position","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/position.py#L198-L234","documentation":"BasePosition.settle_start(settle_type) is an abstract stub that always raises NotImplementedError('Please implement the `settle_conf` method'). It marks the transaction-start hook of the settlement mechanism (delayed cash vs immediate). The message text 'settle_conf' is a typo — the failing method is actually settle_start.","triggerScenarios":"An executor calls position.settle_start(self.ST_CASH) (NestedExecutor with settle_type='cash' in executor config, or SimulatorExecutor wrap-up logic) while the position object's class never overrode settle_start. Instantiating BasePosition directly also triggers it.","commonSituations":"Custom Position subclass copied from an older qlib version that predates the settlement API; executor configured with nested executors and settle: cash while the position class only implements the old interface.","solutions":["Use the built-in Position class, which implements settle_start/settle_commit","Add settle_start to your subclass: store the settle type and initialize cash_delay (mirror Position.settle_start)","Avoid settle_type='cash' executor configs if your custom position cannot support delayed settlement"],"exampleFix":"// before\nclass MyPosition(BasePosition):\n    ...\n\n# after\nclass MyPosition(BasePosition):\n    def settle_start(self, settle_type: str) -> None:\n        assert self._settle_type == self.ST_NO\n        self._settle_type = settle_type\n        if settle_type == self.ST_CASH:\n            self.position[\"cash_delay\"] = 0.0","handlingStrategy":"type-guard","validationCode":"required = (\"settle_start\", \"settle_commit\")\nmissing = [m for m in required if getattr(type(position), m) is getattr(BasePosition, m)]\nassert not missing, f\"position does not implement: {missing}\"","typeGuard":"def supports_settlement(pos) -> bool:\n    return type(pos).settle_start is not BasePosition.settle_start","tryCatchPattern":"try:\n    position.settle_start(settle_type)\nexcept NotImplementedError:\n    # fallback: treat settlement as immediate (ST_NO behaviour)\n    position.settle_start(Position.ST_NO)","preventionTips":["Implement settle_start together with settle_commit as a pair","Do not enable cash settlement executors until the position class passes an interface check"],"tags":["qlib","backtest","abstract-method","settlement","position"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}