microsoft/qlib · error · ValueError
Unsupported deal_price_type: {self.deal_price_type}
Error message
Unsupported deal_price_type: {self.deal_price_type} What it means
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>').
Source
Thrown at qlib/rl/data/pickle_styled.py:141
return f"{self.__class__.__name__}({self.data})"
def __len__(self) -> int:
return len(self.data)
def get_deal_price(self) -> pd.Series:
"""Return a pandas series that can be indexed with time.
See :attribute:`DealPriceType` for details."""
if self.deal_price_type in ("bid_or_ask", "bid_or_ask_fill"):
if self.order_dir is None:
raise ValueError("Order direction cannot be none when deal_price_type is not close.")
if self.order_dir == OrderDir.SELL:
col = "$bid0"
else: # BUY
col = "$ask0"
elif self.deal_price_type == "close":
col = "$close0"
else:
raise ValueError(f"Unsupported deal_price_type: {self.deal_price_type}")
price = self.data[col]
if self.deal_price_type == "bid_or_ask_fill":
if self.order_dir == OrderDir.SELL:
fill_col = "$ask0"
else:
fill_col = "$bid0"
price = price.replace(0, np.nan).fillna(self.data[fill_col])
return price
def get_volume(self) -> pd.Series:
"""Return a volume series that can be indexed with time."""
return self.data["$volume0"]
def get_time_index(self) -> pd.DatetimeIndex:
return cast(pd.DatetimeIndex, self.data.index)
View on GitHub (pinned to 79633dd950)
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
Example fix
# before
data = process_data(deal_price_type='bid/ask') # ValueError
# after
deal_price_type = 'bid_or_ask'
assert deal_price_type in ('close', 'bid_or_ask', 'bid_or_ask_fill')
data = process_data(deal_price_type=deal_price_type) Defensive patterns
Strategy: validation
Validate before calling
assert deal_price_type in ('close', 'bid_or_ask', 'bid_or_ask_fill'), f'unsupported deal_price_type: {deal_price_type!r}' Type guard
def is_valid_deal_price_type(t: str) -> bool:
return t in ('close', 'bid_or_ask', 'bid_or_ask_fill') Try / catch
try:
price = data.get_deal_price()
except ValueError as e:
if 'Unsupported deal_price_type' in str(e):
raise ValueError("deal_price_type must be 'close'/'bid_or_ask'/'bid_or_ask_fill'") from e
raise Prevention
- Validate config strings against the allowed set at load time
- Normalize case and whitespace on config-supplied enum-like strings
When it happens
Trigger: 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.
Common situations: 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').
Related errors
- Order direction cannot be none when deal_price_type is not c
- file "{}" does not exist
- Only py/yml/yaml/json type are supported now!
- Unrecognized data shape: {shape}
- Multiple paths are found with prefix '{filename_without_suff
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/b4b4a95ae09c8bb2.
Report an issue: GitHub.