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: # NOTE:!!!!
  # Strong assumption!!!!!!
  # the correctness of the base_price relies on that the **same** exchange is used
  
  Parameters
  ----------
  inner_order_indicators : List[BaseOrderIndicator]
      the indicators of account of inner executor
  decision_list: List[Tuple[BaseTradeDecision, pd.Timestamp, pd.Timestamp]],
      a list of decisions according to inner_order_indicators
  trade_exchange : Exchange
      for retrieving trading price
  pa_config : dict
      For example
      {
          "agg": "twap",  # "vwap"
          "price": "$close",  # TODO: this is not supported now!!!!!
                              # default to use deal price of the exchange
      }
docstr_tok: ["#","NOTE",":","!","!","!","!","#","Strong","assumption","!","!","!","!","!","!","#","the","correctness","of","the","base_price","relies","on","that","the","*","*","same","*","*","exchange","is","used","Parameters","--","--","--","--","--","inner_order_indicators",":","List","[","BaseOrderIndicator","]","the","indicators","of","account","of","inner","executor","decision_list",":","List","[","Tuple","[","BaseTradeDecision",",","pd.Timestamp",",","pd.Timestamp","]","]",",","a","list","of","decisions","according","to","inner_order_indicators","trade_exchange",":","Exchange","for","retrieving","trading","price","pa_config",":","dict","For","example","{","``","agg","''",":","``","twap","''",",","#","``","vwap","''","``","price","''",":","``","$","close","''",",","#","TODO",":","this","is","not","supported","now","!","!","!","!","!","#","default","to","use","deal","price","of","the","exchange","}"]
code: def _agg_base_price(
      self,
      inner_order_indicators: List[BaseOrderIndicator],
      decision_list: List[
          Tuple[BaseTradeDecision, pd.Timestamp, pd.Timestamp]
      ],
      trade_exchange: Exchange,
      pa_config: dict = {},
  ) -> None:
      """
      # NOTE:!!!!
      # Strong assumption!!!!!!
      # the correctness of the base_price relies on that the **same** exchange is used
  
      Parameters
      ----------
      inner_order_indicators : List[BaseOrderIndicator]
          the indicators of account of inner executor
      decision_list: List[Tuple[BaseTradeDecision, pd.Timestamp, pd.Timestamp]],
          a list of decisions according to inner_order_indicators
      trade_exchange : Exchange
          for retrieving trading price
      pa_config : dict
          For example
          {
              "agg": "twap",  # "vwap"
              "price": "$close",  # TODO: this is not supported now!!!!!
                                  # default to use deal price of the exchange
          }
      """
  
      # TODO: I think there are potentials to be optimized
      trade_dir = self.order_indicator.get_index_data("trade_dir")
      if len(trade_dir) > 0:
          bp_all, bv_all = [], []
          # <step, inst, (base_volume | base_price)>
          for oi, (dec, start, end) in zip(
              inner_order_indicators, decision_list
          ):
              bp_s = oi.get_index_data("base_price").reindex(
                  trade_dir.index
              )
              bv_s = oi.get_index_data("base_volume").reindex(
                  trade_dir.index
              )
  
              bp_new, bv_new = {}, {}
              for pr, v, (inst, direction) in zip(
                  bp_s.data,
                  bv_s.data,
                  zip(trade_dir.index, trade_dir.data),
              ):
                  if np.isnan(pr):
                      bp_tmp, bv_tmp = self._get_base_vol_pri(
                          inst,
                          start,
                          end,
                          decision=dec,
                          direction=direction,
                          trade_exchange=trade_exchange,
                          pa_config=pa_config,
                      )
                      if (bp_tmp is not None) and (bv_tmp is not None):
                          bp_new[inst], bv_new[inst] = bp_tmp, bv_tmp
                  else:
                      bp_new[inst], bv_new[inst] = pr, v
  
              bp_new = idd.SingleData(bp_new)
              bv_new = idd.SingleData(bv_new)
              bp_all.append(bp_new)
              bv_all.append(bv_new)
          bp_all_multi_data = idd.concat(bp_all, axis=1)
          bv_all_multi_data = idd.concat(bv_all, axis=1)
  
          base_volume = bv_all_multi_data.sum(axis=1)
          self.order_indicator.assign(
              "base_volume", base_volume.to_dict()
          )
          self.order_indicator.assign(
              "base_price",
              (
                  (bp_all_multi_data * bv_all_multi_data).sum(axis=1)
                  / base_volume
              ).to_dict(),
          )
  
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 10 for calling the Indicator obj's underlying member method code with example usage: obj._agg_base_price(inner_order_indicators, decision_list, trade_exchange, pa_config) without return types