code: def calc_long_short_prec(
      pred: pd.Series,
      label: pd.Series,
      date_col="datetime",
      quantile: float = 0.2,
      dropna=False,
      is_alpha=False,
  ) -> Tuple[pd.Series, pd.Series]:
      """
      calculate the precision for long and short operation
  
  
      :param pred/label: index is **pd.MultiIndex**, index name is **[datetime, instruments]**; columns names is **[score]**.
  
              .. code-block:: python
                                                    score
                  datetime            instrument
                  2020-12-01 09:30:00 SH600068    0.553634
                                      SH600195    0.550017
                                      SH600276    0.540321
                                      SH600584    0.517297
                                      SH600715    0.544674
      label :
          label
      date_col :
          date_col
  
      Returns
      -------
      (pd.Series, pd.Series)
          long precision and short precision in time level
      """
      if is_alpha:
          label = label - label.mean(level=date_col)
      if int(1 / quantile) >= len(
          label.index.get_level_values(1).unique()
      ):
          raise ValueError(
              "Need more instruments to calculate precision"
          )
  
      df = pd.DataFrame({"pred": pred, "label": label})
      if dropna:
          df.dropna(inplace=True)
  
      group = df.groupby(level=date_col)
  
      def N(x):
          return int(len(x) * quantile)
  
      # find the top/low quantile of prediction and treat them as long and short target
      long = group.apply(
          lambda x: x.nlargest(N(x), columns="pred").label
      ).reset_index(level=0, drop=True)
      short = group.apply(
          lambda x: x.nsmallest(N(x), columns="pred").label
      ).reset_index(level=0, drop=True)
  
      groupll = long.groupby(date_col)
      l_dom = groupll.apply(lambda x: x > 0)
      l_c = groupll.count()
  
      groups = short.groupby(date_col)
      s_dom = groups.apply(lambda x: x < 0)
      s_c = groups.count()
      return (l_dom.groupby(date_col).sum() / l_c), (
          s_dom.groupby(date_col).sum() / s_c
      )
  
file_path: qlib/qlib/contrib/eva/alpha.py
imports: import pandas
  from typing import Tuple
  from qlib import get_module_logger
  from qlib.utils.paral import complex_parallel, DelayedDict
  from joblib import Parallel, delayed
label_desc: Use image node_id 1 for calling a global function with example usage: calc_long_short_prec(pred, label, date_col, quantile, dropna, is_alpha) and returns: unknown,  unknown, int