{"record":{"id":"246a5b98a2ec0afe","repo":"microsoft/qlib","slug":"this-type-of-input-is-not-supported-246a5b","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/contrib/strategy/signal_strategy.py","lineNumber":213,"sourceCode":"        current_stock_list = current_temp.get_stock_list()\n        # last position (sorted by score)\n        last = pred_score.reindex(current_stock_list).sort_values(ascending=False).index\n        # The new stocks today want to buy **at most**\n        if self.method_buy == \"top\":\n            today = get_first_n(\n                pred_score[~pred_score.index.isin(last)].sort_values(ascending=False).index,\n                self.n_drop + self.topk - len(last),\n            )\n        elif self.method_buy == \"random\":\n            topk_candi = get_first_n(pred_score.sort_values(ascending=False).index, self.topk)\n            candi = list(filter(lambda x: x not in last, topk_candi))\n            n = self.n_drop + self.topk - len(last)\n            try:\n                today = np.random.choice(candi, n, replace=False)\n            except ValueError:\n                today = candi\n        else:\n            raise NotImplementedError(f\"This type of input is not supported\")\n        # combine(new stocks + last stocks),  we will drop stocks from this list\n        # In case of dropping higher score stock and buying lower score stock.\n        comb = pred_score.reindex(last.union(pd.Index(today))).sort_values(ascending=False).index\n\n        # Get the stock list we really want to sell (After filtering the case that we sell high and buy low)\n        if self.method_sell == \"bottom\":\n            sell = last[last.isin(get_last_n(comb, self.n_drop))]\n        elif self.method_sell == \"random\":\n            candi = filter_stock(last)\n            try:\n                sell = pd.Index(np.random.choice(candi, self.n_drop, replace=False) if len(last) else [])\n            except ValueError:  # No enough candidates\n                sell = candi\n        else:\n            raise NotImplementedError(f\"This type of input is not supported\")\n\n        # Get the stock list we really want to buy\n        buy = today[: len(sell) + self.topk - len(last)]","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/contrib/strategy/signal_strategy.py#L195-L231","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nstrategy = TopkDropoutStrategy(signal=signal, topk=50, n_drop=5, method_buy='Best')\n\n# after\nstrategy = TopkDropoutStrategy(signal=signal, topk=50, n_drop=5, method_buy='bottom')","handlingStrategy":"validation","validationCode":"method_buy = 'bottom'\nassert method_buy in ('bottom', 'random'), f'unsupported method_buy: {method_buy!r}'\nstrategy = TopkDropoutStrategy(signal=signal, method_buy=method_buy, ...)","typeGuard":"def is_valid_buy_method(m: str) -> bool:\n    return m in {'bottom', 'random'}","tryCatchPattern":null,"preventionTips":["Whitelist method_buy/method_sell to {'bottom','random'} in config validation before constructing the strategy","Values are case-sensitive lowercase strings"],"tags":["qlib","strategy","topk-dropout","configuration"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}