docstr: Parameters
  -----------
  topk : int
      the number of stocks in the portfolio.
  n_drop : int
      number of stocks to be replaced in each trading date.
  method_sell : str
      dropout method_sell, random/bottom.
  method_buy : str
      dropout method_buy, random/top.
  hold_thresh : int
      minimum holding days
      before sell stock , will check current.get_stock_count(order.stock_id) >= self.hold_thresh.
  only_tradable : bool
      will the strategy only consider the tradable stock when buying and selling.
  
      if only_tradable:
  
          strategy will make decision with the tradable state of the stock info and avoid buy and sell them.
  
      else:
  
          strategy will make buy sell decision without checking the tradable state of the stock.
  forbid_all_trade_at_limit : bool
      if forbid all trades when limit_up or limit_down reached.
  
      if forbid_all_trade_at_limit:
  
          strategy will not do any trade when price reaches limit up/down, even not sell at limit up nor buy at
          limit down, though allowed in reality.
  
      else:
  
          strategy will sell at limit up and buy ad limit down.
docstr_tok: ["Parameters","--","--","--","--","--","-","topk",":","int","the","number","of","stocks","in","the","portfolio",".","n_drop",":","int","number","of","stocks","to","be","replaced","in","each","trading","date",".","method_sell",":","str","dropout","method_sell",",","random\/bottom",".","method_buy",":","str","dropout","method_buy",",","random\/top",".","hold_thresh",":","int","minimum","holding","days","before","sell","stock",",","will","check","current.get_stock_count","(","order.stock_id",")",">","=","self.hold_thresh",".","only_tradable",":","bool","will","the","strategy","only","consider","the","tradable","stock","when","buying","and","selling",".","if","only_tradable",":","strategy","will","make","decision","with","the","tradable","state","of","the","stock","info","and","avoid","buy","and","sell","them",".","else",":","strategy","will","make","buy","sell","decision","without","checking","the","tradable","state","of","the","stock",".","forbid_all_trade_at_limit",":","bool","if","forbid","all","trades","when","limit_up","or","limit_down","reached",".","if","forbid_all_trade_at_limit",":","strategy","will","not","do","any","trade","when","price","reaches","limit","up\/down",",","even","not","sell","at","limit","up","nor","buy","at","limit","down",",","though","allowed","in","reality",".","else",":","strategy","will","sell","at","limit","up","and","buy","ad","limit","down","."]
code: def __init__(
      self,
      *,
      topk,
      n_drop,
      method_sell="bottom",
      method_buy="top",
      hold_thresh=1,
      only_tradable=False,
      forbid_all_trade_at_limit=True,
      **kwargs,
  ):
      """
      Parameters
      -----------
      topk : int
          the number of stocks in the portfolio.
      n_drop : int
          number of stocks to be replaced in each trading date.
      method_sell : str
          dropout method_sell, random/bottom.
      method_buy : str
          dropout method_buy, random/top.
      hold_thresh : int
          minimum holding days
          before sell stock , will check current.get_stock_count(order.stock_id) >= self.hold_thresh.
      only_tradable : bool
          will the strategy only consider the tradable stock when buying and selling.
  
          if only_tradable:
  
              strategy will make decision with the tradable state of the stock info and avoid buy and sell them.
  
          else:
  
              strategy will make buy sell decision without checking the tradable state of the stock.
      forbid_all_trade_at_limit : bool
          if forbid all trades when limit_up or limit_down reached.
  
          if forbid_all_trade_at_limit:
  
              strategy will not do any trade when price reaches limit up/down, even not sell at limit up nor buy at
              limit down, though allowed in reality.
  
          else:
  
              strategy will sell at limit up and buy ad limit down.
      """
      super().__init__(**kwargs)
      self.topk = topk
      self.n_drop = n_drop
      self.method_sell = method_sell
      self.method_buy = method_buy
      self.hold_thresh = hold_thresh
      self.only_tradable = only_tradable
      self.forbid_all_trade_at_limit = forbid_all_trade_at_limit
  
imports: import os
  import copy
  import warnings
  import numpy
  import pandas
  from typing import Dict, List, Text, Tuple, Union
  from abc import ABC
  from qlib.data import D
  from qlib.data.dataset import Dataset
  from qlib.model.base import BaseModel
  from qlib.strategy.base import BaseStrategy
  from qlib.backtest.position import Position
  from qlib.backtest.signal import Signal, create_signal_from
  from qlib.backtest.decision import Order, OrderDir, TradeDecisionWO
  from qlib.log import get_module_logger
  from qlib.utils import get_pre_trading_date, load_dataset
  from qlib.contrib.strategy.order_generator import OrderGenerator, OrderGenWOInteract
  from qlib.contrib.strategy.optimizer import EnhancedIndexingOptimizer
label_desc: Use image node_id 1 to create a new TopkDropoutStrategy object from inherited base classes: BaseSignalStrategy with example: obj = TopkDropoutStrategy()