code: def parse_position(position: dict = None) -> pd.DataFrame:
      """Parse position dict to position DataFrame
  
      :param position: position data
      :return: position DataFrame;
  
  
          .. code-block:: python
  
              position_df = parse_position(positions)
              print(position_df.head())
              # status: 0-hold, -1-sell, 1-buy
  
                                          amount      cash      count    price status weight
              instrument  datetime
              SZ000547    2017-01-04  44.154290   211405.285654   1   205.189575  1   0.031255
              SZ300202    2017-01-04  60.638845   211405.285654   1   154.356506  1   0.032290
              SH600158    2017-01-04  46.531681   211405.285654   1   153.895142  1   0.024704
              SH600545    2017-01-04  197.173093  211405.285654   1   48.607037   1   0.033063
              SZ000930    2017-01-04  103.938300  211405.285654   1   80.759453   1   0.028958
  
  
      """
  
      position_weight_df = get_stock_weight_df(position)
      # If the day does not exist, use the last weight
      position_weight_df.fillna(method="ffill", inplace=True)
  
      previous_data = {"date": None, "code_list": []}
  
      result_df = pd.DataFrame()
      for _trading_date, _value in position.items():
          _value = _value.position
          # pd_date type: pd.Timestamp
          _cash = _value.pop("cash")
          for _item in ["now_account_value"]:
              if _item in _value:
                  _value.pop(_item)
  
          _trading_day_df = pd.DataFrame.from_dict(
              _value, orient="index"
          )
          _trading_day_df["weight"] = position_weight_df.loc[
              _trading_date
          ]
          _trading_day_df["cash"] = _cash
          _trading_day_df["date"] = _trading_date
          # status: 0-hold, -1-sell, 1-buy
          _trading_day_df["status"] = 0
  
          # T not exist, T-1 exist, T sell
          _cur_day_sell = set(previous_data["code_list"]) - set(
              _trading_day_df.index
          )
          # T exist, T-1 not exist, T buy
          _cur_day_buy = set(_trading_day_df.index) - set(
              previous_data["code_list"]
          )
  
          # Trading day buy
          _trading_day_df.loc[
              _trading_day_df.index.isin(_cur_day_buy), "status"
          ] = 1
  
          # Trading day sell
          if not result_df.empty:
              _trading_day_sell_df = result_df.loc[
                  (result_df["date"] == previous_data["date"])
                  & (result_df.index.isin(_cur_day_sell))
              ].copy()
              if not _trading_day_sell_df.empty:
                  _trading_day_sell_df["status"] = -1
                  _trading_day_sell_df["date"] = _trading_date
                  _trading_day_df = pd.concat(
                      [_trading_day_df, _trading_day_sell_df],
                      sort=False,
                  )
  
          result_df = pd.concat([result_df, _trading_day_df], sort=True)
  
          previous_data = dict(
              date=_trading_date,
              code_list=_trading_day_df[
                  _trading_day_df["status"] != -1
              ].index,
          )
  
      result_df.reset_index(inplace=True)
      result_df.rename(
          columns={"date": "datetime", "index": "instrument"},
          inplace=True,
      )
      return result_df.set_index(["instrument", "datetime"])
  
imports: import pandas
  from ....backtest.profit_attribution import get_stock_weight_df
label_desc: Use image node_id 1 for calling a global function with example usage: parse_position(position) and returns: result_df