{"record":{"id":"b4b4a95ae09c8bb2","repo":"microsoft/qlib","slug":"unsupported-deal-price-type-self-deal-price-type","errorCode":null,"errorMessage":"Unsupported deal_price_type: {self.deal_price_type}","messagePattern":"Unsupported deal_price_type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/rl/data/pickle_styled.py","lineNumber":141,"sourceCode":"            return f\"{self.__class__.__name__}({self.data})\"\n\n    def __len__(self) -> int:\n        return len(self.data)\n\n    def get_deal_price(self) -> pd.Series:\n        \"\"\"Return a pandas series that can be indexed with time.\n        See :attribute:`DealPriceType` for details.\"\"\"\n        if self.deal_price_type in (\"bid_or_ask\", \"bid_or_ask_fill\"):\n            if self.order_dir is None:\n                raise ValueError(\"Order direction cannot be none when deal_price_type is not close.\")\n            if self.order_dir == OrderDir.SELL:\n                col = \"$bid0\"\n            else:  # BUY\n                col = \"$ask0\"\n        elif self.deal_price_type == \"close\":\n            col = \"$close0\"\n        else:\n            raise ValueError(f\"Unsupported deal_price_type: {self.deal_price_type}\")\n        price = self.data[col]\n\n        if self.deal_price_type == \"bid_or_ask_fill\":\n            if self.order_dir == OrderDir.SELL:\n                fill_col = \"$ask0\"\n            else:\n                fill_col = \"$bid0\"\n            price = price.replace(0, np.nan).fillna(self.data[fill_col])\n\n        return price\n\n    def get_volume(self) -> pd.Series:\n        \"\"\"Return a volume series that can be indexed with time.\"\"\"\n        return self.data[\"$volume0\"]\n\n    def get_time_index(self) -> pd.DatetimeIndex:\n        return cast(pd.DatetimeIndex, self.data.index)\n","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/rl/data/pickle_styled.py#L123-L159","documentation":"get_deal_price (qlib/rl/data/pickle_styled.py:141) supports exactly three deal_price_type values: 'close' (column $close0), 'bid_or_ask', and 'bid_or_ask_fill'. Any other string (typos like 'bid_or_close', 'mid', 'vwap', empty string) falls to the else branch and raises ValueError('Unsupported deal_price_type: <value>').","triggerScenarios":"Constructing pickle-styled data/order objects with deal_price_type not in {'close', 'bid_or_ask', 'bid_or_ask_fill'}; copy-pasted configs with typos; passing 'bid/ask' or 'bidask' variants.","commonSituations":"Config-driven backtests where the deal_price_type string comes from YAML; users attempting to add custom price types without subclassing; whitespace/case differences ('Close' vs 'close').","solutions":["Use one of the supported values exactly: 'close', 'bid_or_ask', or 'bid_or_ask_fill'","Normalize/validate the config string (strip whitespace, lower-case) before passing it","For custom price columns, subclass and override get_deal_price instead of inventing a new type string"],"exampleFix":"# before\ndata = process_data(deal_price_type='bid/ask')  # ValueError\n\n# after\ndeal_price_type = 'bid_or_ask'\nassert deal_price_type in ('close', 'bid_or_ask', 'bid_or_ask_fill')\ndata = process_data(deal_price_type=deal_price_type)","handlingStrategy":"validation","validationCode":"assert deal_price_type in ('close', 'bid_or_ask', 'bid_or_ask_fill'), f'unsupported deal_price_type: {deal_price_type!r}'","typeGuard":"def is_valid_deal_price_type(t: str) -> bool:\n    return t in ('close', 'bid_or_ask', 'bid_or_ask_fill')","tryCatchPattern":"try:\n    price = data.get_deal_price()\nexcept ValueError as e:\n    if 'Unsupported deal_price_type' in str(e):\n        raise ValueError(\"deal_price_type must be 'close'/'bid_or_ask'/'bid_or_ask_fill'\") from e\n    raise","preventionTips":["Validate config strings against the allowed set at load time","Normalize case and whitespace on config-supplied enum-like strings"],"tags":["qlib","rl","deal-price","config","value-error"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}