class_docstr: `Indicator` is implemented in a aggregate way.
  All the metrics are calculated aggregately.
  All the metrics are calculated for a separated stock and in a specific step on a specific level.
  
  | indicator    | desc.                                                        |
  |--------------+--------------------------------------------------------------|
  | amount       | the *target* amount given by the outer strategy              |
  | deal_amount  | the real deal amount                                         |
  | inner_amount | the total *target* amount of inner strategy                  |
  | trade_price  | the average deal price                                       |
  | trade_value  | the total trade value                                        |
  | trade_cost   | the total trade cost  (base price need drection)             |
  | trade_dir    | the trading direction                                        |
  | ffr          | full fill rate                                               |
  | pa           | price advantage                                              |
  | pos          | win rate                                                     |
  | base_price   | the price of baseline                                        |
  | base_volume  | the volume of baseline (for weighted aggregating base_price) |
  
  **NOTE**:
  The `base_price` and `base_volume` can't be NaN when there are not trading on that step. Otherwise
  aggregating get wrong results.
  
  So `base_price` will not be calculated in a aggregate way!!
class_docstr_tok: ["`","Indicator","`","is","implemented","in","a","aggregate","way",".","All","the","metrics","are","calculated","aggregately",".","All","the","metrics","are","calculated","for","a","separated","stock","and","in","a","specific","step","on","a","specific","level",".","|","indicator","|","desc",".","|","|","--","--","--","--","--","--","--","+","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","|","|","amount","|","the","*","target","*","amount","given","by","the","outer","strategy","|","|","deal_amount","|","the","real","deal","amount","|","|","inner_amount","|","the","total","*","target","*","amount","of","inner","strategy","|","|","trade_price","|","the","average","deal","price","|","|","trade_value","|","the","total","trade","value","|","|","trade_cost","|","the","total","trade","cost","(","base","price","need","drection",")","|","|","trade_dir","|","the","trading","direction","|","|","ffr","|","full","fill","rate","|","|","pa","|","price","advantage","|","|","pos","|","win","rate","|","|","base_price","|","the","price","of","baseline","|","|","base_volume","|","the","volume","of","baseline","(","for","weighted","aggregating","base_price",")","|","*","*","NOTE","*","*",":","The","`","base_price","`","and","`","base_volume","`","ca","n't","be","NaN","when","there","are","not","trading","on","that","step",".","Otherwise","aggregating","get","wrong","results",".","So","`","base_price","`","will","not","be","calculated","in","a","aggregate","way","!","!"]
docstr: Get the base volume and price information
  All the base price values are rooted from this function
docstr_tok: ["Get","the","base","volume","and","price","information","All","the","base","price","values","are","rooted","from","this","function"]
code: def _get_base_vol_pri(
      self,
      inst: str,
      trade_start_time: pd.Timestamp,
      trade_end_time: pd.Timestamp,
      direction: OrderDir,
      decision: BaseTradeDecision,
      trade_exchange: Exchange,
      pa_config: dict = {},
  ) -> Tuple[Optional[float], Optional[float]]:
      """
      Get the base volume and price information
      All the base price values are rooted from this function
      """
  
      agg = pa_config.get("agg", "twap").lower()
      price = pa_config.get("price", "deal_price").lower()
  
      if decision.trade_range is not None:
          (
              trade_start_time,
              trade_end_time,
          ) = decision.trade_range.clip_time_range(
              start_time=trade_start_time,
              end_time=trade_end_time,
          )
  
      if price == "deal_price":
          price_s = trade_exchange.get_deal_price(
              inst,
              trade_start_time,
              trade_end_time,
              direction=direction,
              method=None,
          )
      else:
          raise NotImplementedError(
              f"This type of input is not supported"
          )
  
      # if there is no stock data during the time period
      if price_s is None:
          return None, None
  
      if isinstance(price_s, (int, float, np.number)):
          price_s = idd.SingleData(price_s, [trade_start_time])
      elif isinstance(price_s, idd.SingleData):
          pass
      else:
          raise NotImplementedError(
              f"This type of input is not supported"
          )
  
      # NOTE: there are some zeros in the trading price. These cases are known meaningless
      # for aligning the previous logic, remove it.
      # remove zero and negative values.
      assert isinstance(price_s, idd.SingleData)
      price_s = price_s.loc[(price_s > 1e-08).data.astype(bool)]
      # NOTE ~(price_s < 1e-08) is different from price_s >= 1e-8
      #   ~(np.NaN < 1e-8) -> ~(False)  -> True
  
      assert isinstance(price_s, idd.SingleData)
      if agg == "vwap":
          volume_s = trade_exchange.get_volume(
              inst, trade_start_time, trade_end_time, method=None
          )
          if isinstance(volume_s, (int, float, np.number)):
              volume_s = idd.SingleData(volume_s, [trade_start_time])
          assert isinstance(volume_s, idd.SingleData)
          volume_s = volume_s.reindex(price_s.index)
      elif agg == "twap":
          volume_s = idd.SingleData(1, price_s.index)
      else:
          raise NotImplementedError(
              f"This type of input is not supported"
          )
  
      assert isinstance(volume_s, idd.SingleData)
      base_volume = volume_s.sum()
      base_price = (price_s * volume_s).sum() / base_volume
      return base_price, base_volume
  
imports: from __future__ import annotations
  import pathlib
  from collections import OrderedDict
  from typing import Any, Dict, List, Optional, Text, Tuple, Type, Union, cast
  import numpy
  import pandas
  import qlib.utils.index_data
  from qlib.backtest.decision import BaseTradeDecision, Order, OrderDir
  from qlib.backtest.exchange import Exchange
  from ..tests.config import CSI300_BENCH
  from ..utils.resam import get_higher_eq_freq_feature, resam_ts_data
  from .high_performance_ds import BaseOrderIndicator, BaseSingleMetric, NumpyOrderIndicator
label_desc: Use image node_id 9 for calling the Indicator obj's underlying member method code with example usage: obj._get_base_vol_pri(inst, trade_start_time, trade_end_time, direction, decision, trade_exchange, pa_config) and returns: base_price,  base_volume, None,  None