code: def _get_cum_return_data_with_position(
      position: dict,
      report_normal: pd.DataFrame,
      label_data: pd.DataFrame,
      start_date=None,
      end_date=None,
  ):
      """
  
      :param position:
      :param report_normal:
      :param label_data:
      :param start_date:
      :param end_date:
      :return:
      """
      _cumulative_return_df = get_position_data(
          position=position,
          report_normal=report_normal,
          label_data=label_data,
          start_date=start_date,
          end_date=end_date,
      ).copy()
  
      _cumulative_return_df["label"] = (
          _cumulative_return_df["label"]
          - _cumulative_return_df["bench"]
      )
      _cumulative_return_df = _cumulative_return_df.dropna()
      df_gp = _cumulative_return_df.groupby(level="datetime")
      result_list = []
      for gp in df_gp:
          date = gp[0]
          day_df = gp[1]
  
          _hold_df = day_df[day_df["status"] == 0]
          _buy_df = day_df[day_df["status"] == 1]
          _sell_df = day_df[day_df["status"] == -1]
  
          hold_value = (_hold_df["label"] * _hold_df["weight"]).sum()
          hold_weight = _hold_df["weight"].sum()
          hold_mean = (hold_value / hold_weight) if hold_weight else 0
  
          sell_value = (_sell_df["label"] * _sell_df["weight"]).sum()
          sell_weight = _sell_df["weight"].sum()
          sell_mean = (sell_value / sell_weight) if sell_weight else 0
  
          buy_value = (_buy_df["label"] * _buy_df["weight"]).sum()
          buy_weight = _buy_df["weight"].sum()
          buy_mean = (buy_value / buy_weight) if buy_weight else 0
  
          result_list.append(
              dict(
                  hold_value=hold_value,
                  hold_mean=hold_mean,
                  hold_weight=hold_weight,
                  buy_value=buy_value,
                  buy_mean=buy_mean,
                  buy_weight=buy_weight,
                  sell_value=sell_value,
                  sell_mean=sell_mean,
                  sell_weight=sell_weight,
                  buy_minus_sell_value=buy_value - sell_value,
                  buy_minus_sell_mean=buy_mean - sell_mean,
                  buy_plus_sell_weight=buy_weight + sell_weight,
                  date=date,
              )
          )
  
      r_df = pd.DataFrame(data=result_list)
      r_df["cum_hold"] = r_df["hold_mean"].cumsum()
      r_df["cum_buy"] = r_df["buy_mean"].cumsum()
      r_df["cum_sell"] = r_df["sell_mean"].cumsum()
      r_df["cum_buy_minus_sell"] = r_df["buy_minus_sell_mean"].cumsum()
      return r_df
  
file_path: qlib/qlib/contrib/report/analysis_position/cumulative_return.py
imports: import copy
  from typing import Iterable
  import pandas
  import plotly.graph_objs
  from ..graph import BaseGraph, SubplotsGraph
  from ..analysis_position.parse_position import get_position_data
label_desc: Use image node_id 1 for calling a global function with example usage: _get_cum_return_data_with_position(position, report_normal, label_data, start_date, end_date) and returns: r_df