microsoft/qlib · error · NotImplementedError
This type of input is not supported
Error message
This type of input is not supported
What it means
TopkDropoutStrategy.trade_buy-side selection (qlib/contrib/strategy/signal_strategy.py) supports only two buying methods: 'bottom' (deterministic, from the bottom of the previous holdings to refill topk) and 'random' (random refill from top-k candidates). Any other method_buy string raises NotImplementedError.
Source
Thrown at qlib/contrib/strategy/signal_strategy.py:213
current_stock_list = current_temp.get_stock_list()
# last position (sorted by score)
last = pred_score.reindex(current_stock_list).sort_values(ascending=False).index
# The new stocks today want to buy **at most**
if self.method_buy == "top":
today = get_first_n(
pred_score[~pred_score.index.isin(last)].sort_values(ascending=False).index,
self.n_drop + self.topk - len(last),
)
elif self.method_buy == "random":
topk_candi = get_first_n(pred_score.sort_values(ascending=False).index, self.topk)
candi = list(filter(lambda x: x not in last, topk_candi))
n = self.n_drop + self.topk - len(last)
try:
today = np.random.choice(candi, n, replace=False)
except ValueError:
today = candi
else:
raise NotImplementedError(f"This type of input is not supported")
# combine(new stocks + last stocks), we will drop stocks from this list
# In case of dropping higher score stock and buying lower score stock.
comb = pred_score.reindex(last.union(pd.Index(today))).sort_values(ascending=False).index
# Get the stock list we really want to sell (After filtering the case that we sell high and buy low)
if self.method_sell == "bottom":
sell = last[last.isin(get_last_n(comb, self.n_drop))]
elif self.method_sell == "random":
candi = filter_stock(last)
try:
sell = pd.Index(np.random.choice(candi, self.n_drop, replace=False) if len(last) else [])
except ValueError: # No enough candidates
sell = candi
else:
raise NotImplementedError(f"This type of input is not supported")
# Get the stock list we really want to buy
buy = today[: len(sell) + self.topk - len(last)]View on GitHub (pinned to 79633dd950)
Solutions
- Set method_buy='bottom' or method_buy='random' (lowercase, exact match)
- Check for typos/case in your strategy config
- For custom buy logic, subclass TopkDropoutStrategy and override the buy-candidate selection rather than passing a new method string
Example fix
# before strategy = TopkDropoutStrategy(signal=signal, topk=50, n_drop=5, method_buy='Best') # after strategy = TopkDropoutStrategy(signal=signal, topk=50, n_drop=5, method_buy='bottom')
Defensive patterns
Strategy: validation
Validate before calling
method_buy = 'bottom'
assert method_buy in ('bottom', 'random'), f'unsupported method_buy: {method_buy!r}'
strategy = TopkDropoutStrategy(signal=signal, method_buy=method_buy, ...) Type guard
def is_valid_buy_method(m: str) -> bool:
return m in {'bottom', 'random'} Prevention
- Whitelist method_buy/method_sell to {'bottom','random'} in config validation before constructing the strategy
- Values are case-sensitive lowercase strings
When it happens
Trigger: Constructing TopkDropoutStrategy(..., method_buy='best') or any value outside {'bottom','random'}, then running generate_trade_decision during a backtest; the error fires on the first trade step where buying occurs.
Common situations: Copying example configs that later added the method_buy/method_sell knobs with unsupported values; typos or case differences ('Random', 'BOTTOM'); assuming pluggable buy methods exist.
Related errors
- inner_order_indicators is necessary in un-atomic executor
- unknown loss `%s`
- unknown metric `%s`
- Empty data from dataset, please check your dataset config.
- optimizer {} is not supported!
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/246a5b98a2ec0afe.
Report an issue: GitHub.