class_docstr: Hashing data storage for datahanlder
  - The default data storage pandas.DataFrame is too slow when randomly accessing one stock's data
  - HashingStockStorage hashes the multiple stocks' data(pandas.DataFrame) by the key `stock_id`.
  - HashingStockStorage hashes the pandas.DataFrame into a dict, whose key is the stock_id(str) and value this stock data(panda.DataFrame), it has the following format:
      {
          stock1_id: stock1_data,
          stock2_id: stock2_data,
          ...
          stockn_id: stockn_data,
      }
  - By the `fetch` method, users can access any stock data with much lower time cost than default data storage
class_docstr_tok: ["Hashing","data","storage","for","datahanlder","-","The","default","data","storage","pandas.DataFrame","is","too","slow","when","randomly","accessing","one","stock","'s","data","-","HashingStockStorage","hashes","the","multiple","stocks","'","data","(","pandas.DataFrame",")","by","the","key","`","stock_id","`",".","-","HashingStockStorage","hashes","the","pandas.DataFrame","into","a","dict",",","whose","key","is","the","stock_id","(","str",")","and","value","this","stock","data","(","panda.DataFrame",")",",","it","has","the","following","format",":","{","stock1_id",":","stock1_data",",","stock2_id",":","stock2_data",",","...","stockn_id",":","stockn_data",",","}","-","By","the","`","fetch","`","method",",","users","can","access","any","stock","data","with","much","lower","time","cost","than","default","data","storage"]
docstr: fetch the data with stock selector
  
  Parameters
  ----------
  selector : Union[pd.Timestamp, slice, str]
      describe how to select data by index
  level : Union[str, int]
      which index level to select the data
      - if level is None, apply selector to df directly
      - the `_fetch_hash_df_by_stock` will parse the stock selector in arg `selector`
  
  Returns
  -------
  Dict
      The dict whose key is stock_id, value is the stock's data
docstr_tok: ["fetch","the","data","with","stock","selector","Parameters","--","--","--","--","--","selector",":","Union","[","pd.Timestamp",",","slice",",","str","]","describe","how","to","select","data","by","index","level",":","Union","[","str",",","int","]","which","index","level","to","select","the","data","-","if","level","is","None",",","apply","selector","to","df","directly","-","the","`","_fetch_hash_df_by_stock","`","will","parse","the","stock","selector","in","arg","`","selector","`","Returns","--","--","--","-","Dict","The","dict","whose","key","is","stock_id",",","value","is","the","stock","'s","data"]
code: def _fetch_hash_df_by_stock(self, selector, level):
      """fetch the data with stock selector
  
      Parameters
      ----------
      selector : Union[pd.Timestamp, slice, str]
          describe how to select data by index
      level : Union[str, int]
          which index level to select the data
          - if level is None, apply selector to df directly
          - the `_fetch_hash_df_by_stock` will parse the stock selector in arg `selector`
  
      Returns
      -------
      Dict
          The dict whose key is stock_id, value is the stock's data
      """
  
      stock_selector = slice(None)
  
      if level is None:
          if isinstance(selector, tuple) and self.stock_level < len(
              selector
          ):
              stock_selector = selector[self.stock_level]
          elif (
              isinstance(selector, (list, str))
              and self.stock_level == 0
          ):
              stock_selector = selector
      elif level in ("instrument", self.stock_level):
          if isinstance(selector, tuple):
              stock_selector = selector[0]
          elif isinstance(selector, (list, str)):
              stock_selector = selector
  
      if not isinstance(
          stock_selector, (list, str)
      ) and stock_selector != slice(None):
          raise TypeError(
              f"stock selector must be type str|list, or slice(None), rather than {stock_selector}"
          )
  
      if stock_selector == slice(None):
          return self.hash_df
  
      if isinstance(stock_selector, str):
          stock_selector = [stock_selector]
  
      select_dict = dict()
      for each_stock in sorted(stock_selector):
          if each_stock in self.hash_df:
              select_dict[each_stock] = self.hash_df[each_stock]
      return select_dict
  
file_path: qlib/qlib/data/dataset/storage.py
imports: import pandas
  import numpy
  from .handler import DataHandler
  from typing import Union, List, Callable
  from .utils import get_level_index, fetch_df_by_index, fetch_df_by_col
label_desc: Use image node_id 3 for calling the HashingStockStorage obj's underlying member method code with example usage: obj._fetch_hash_df_by_stock(selector, level) and returns: select_dict, self