{"record":{"id":"80ed3e007d096074","repo":"microsoft/qlib","slug":"this-type-of-input-is-not-supported-80ed3e","errorCode":null,"errorMessage":"This type of input is not supported","messagePattern":"This type of input is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/backtest/position.py","lineNumber":382,"sourceCode":"                # decrease the amount of stock\n                self.position[stock_id][\"amount\"] -= trade_amount\n                # check if to delete\n                if self.position[stock_id][\"amount\"] < -1e-5:\n                    raise ValueError(\n                        \"only have {} {}, require {}\".format(\n                            self.position[stock_id][\"amount\"] + trade_amount,\n                            stock_id,\n                            trade_amount,\n                        ),\n                    )\n\n        new_cash = trade_val - cost\n        if self._settle_type == self.ST_CASH:\n            self.position[\"cash_delay\"] += new_cash\n        elif self._settle_type == self.ST_NO:\n            self.position[\"cash\"] += new_cash\n        else:\n            raise NotImplementedError(f\"This type of input is not supported\")\n\n    def _del_stock(self, stock_id: str) -> None:\n        del self.position[stock_id]\n\n    def check_stock(self, stock_id: str) -> bool:\n        return stock_id in self.position\n\n    def update_order(self, order: Order, trade_val: float, cost: float, trade_price: float) -> None:\n        # handle order, order is a order class, defined in exchange.py\n        if order.direction == Order.BUY:\n            # BUY\n            self._buy_stock(order.stock_id, trade_val, cost, trade_price)\n        elif order.direction == Order.SELL:\n            # SELL\n            self._sell_stock(order.stock_id, trade_val, cost, trade_price)\n        else:\n            raise NotImplementedError(\"do not support order direction {}\".format(order.direction))\n","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/position.py#L364-L400","documentation":"In Position._sell_stock, after computing new_cash = trade_val - cost the code routes the proceeds by self._settle_type: ST_CASH goes to position['cash_delay'], ST_NO goes directly to 'cash'. Any other value hits NotImplementedError('This type of input is not supported'). _settle_type is set by settle_start(settle_type), so this fires when settle_start was called with an unrecognized settle type.","triggerScenarios":"Calling position.settle_start(some_type) with some_type not in {'cash', 'None'} and then executing a sell order. The ST_CASH/ST_NO string constants are defined in BasePosition; passing e.g. None (the object) or 'delayed' triggers it.","commonSituations":"Custom nested executor passing a novel settle_type; passing Python None instead of the string 'None' (ST_NO = 'None' is deliberately a string); typos like 'Cash' or 'CASH'.","solutions":["Use only the class constants: position.settle_start(Position.ST_CASH) or Position.ST_NO","If passing the string, use exactly 'cash' or 'None' — note ST_NO is the string 'None', not Python None","Patch settle_start to validate settle_type up front instead of failing later mid-trade"],"exampleFix":"# before\nposition.settle_start(None)        # Python None -> falls through both branches\n\n# after\nposition.settle_start(Position.ST_NO)  # the string \"None\"","handlingStrategy":"validation","validationCode":"VALID = {Position.ST_CASH, Position.ST_NO}\nassert settle_type in VALID, f\"settle_type must be one of {VALID}, got {settle_type!r}\"","typeGuard":"def is_valid_settle_type(t: str) -> bool:\n    return t in (Position.ST_CASH, Position.ST_NO)","tryCatchPattern":"try:\n    position.update_order(order, trade_val, cost, trade_price)\nexcept NotImplementedError as e:\n    raise ValueError(f\"bad settle_type {position._settle_type!r}\") from e","preventionTips":["Use class constants ST_CASH/ST_NO, never literals","Remember ST_NO is the string 'None', not Python None","Validate settle_type at settle_start time"],"tags":["qlib","backtest","settlement","position","invalid-argument"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}