code: def risk_analysis_graph(
      analysis_df: pd.DataFrame = None,
      report_normal_df: pd.DataFrame = None,
      report_long_short_df: pd.DataFrame = None,
      show_notebook: bool = True,
  ) -> Iterable[py.Figure]:
      """Generate analysis graph and monthly analysis
  
          Example:
  
  
              .. code-block:: python
  
                  import qlib
                  import pandas as pd
                  from qlib.utils.time import Freq
                  from qlib.utils import flatten_dict
                  from qlib.backtest import backtest, executor
                  from qlib.contrib.evaluate import risk_analysis
                  from qlib.contrib.strategy import TopkDropoutStrategy
  
                  # init qlib
                  qlib.init(provider_uri=<qlib data dir>)
  
                  CSI300_BENCH = "SH000300"
                  FREQ = "day"
                  STRATEGY_CONFIG = {
                      "topk": 50,
                      "n_drop": 5,
                      # pred_score, pd.Series
                      "signal": pred_score,
                  }
  
                  EXECUTOR_CONFIG = {
                      "time_per_step": "day",
                      "generate_portfolio_metrics": True,
                  }
  
                  backtest_config = {
                      "start_time": "2017-01-01",
                      "end_time": "2020-08-01",
                      "account": 100000000,
                      "benchmark": CSI300_BENCH,
                      "exchange_kwargs": {
                          "freq": FREQ,
                          "limit_threshold": 0.095,
                          "deal_price": "close",
                          "open_cost": 0.0005,
                          "close_cost": 0.0015,
                          "min_cost": 5,
                      },
                  }
  
                  # strategy object
                  strategy_obj = TopkDropoutStrategy(**STRATEGY_CONFIG)
                  # executor object
                  executor_obj = executor.SimulatorExecutor(**EXECUTOR_CONFIG)
                  # backtest
                  portfolio_metric_dict, indicator_dict = backtest(executor=executor_obj, strategy=strategy_obj, **backtest_config)
                  analysis_freq = "{0}{1}".format(*Freq.parse(FREQ))
                  # backtest info
                  report_normal_df, positions_normal = portfolio_metric_dict.get(analysis_freq)
                  analysis = dict()
                  analysis["excess_return_without_cost"] = risk_analysis(
                      report_normal_df["return"] - report_normal_df["bench"], freq=analysis_freq
                  )
                  analysis["excess_return_with_cost"] = risk_analysis(
                      report_normal_df["return"] - report_normal_df["bench"] - report_normal_df["cost"], freq=analysis_freq
                  )
  
                  analysis_df = pd.concat(analysis)  # type: pd.DataFrame
                  analysis_position.risk_analysis_graph(analysis_df, report_normal_df)
  
  
  
      :param analysis_df: analysis data, index is **pd.MultiIndex**; columns names is **[risk]**.
  
  
              .. code-block:: python
  
                                                                    risk
                  excess_return_without_cost mean               0.000692
                                             std                0.005374
                                             annualized_return  0.174495
                                             information_ratio  2.045576
                                             max_drawdown      -0.079103
                  excess_return_with_cost    mean               0.000499
                                             std                0.005372
                                             annualized_return  0.125625
                                             information_ratio  1.473152
                                             max_drawdown      -0.088263
  
  
      :param report_normal_df: **df.index.name** must be **date**, df.columns must contain **return**, **turnover**, **cost**, **bench**.
  
  
              .. code-block:: python
  
                              return      cost        bench       turnover
                  date
                  2017-01-04  0.003421    0.000864    0.011693    0.576325
                  2017-01-05  0.000508    0.000447    0.000721    0.227882
                  2017-01-06  -0.003321   0.000212    -0.004322   0.102765
                  2017-01-09  0.006753    0.000212    0.006874    0.105864
                  2017-01-10  -0.000416   0.000440    -0.003350   0.208396
  
  
      :param report_long_short_df: **df.index.name** must be **date**, df.columns contain **long**, **short**, **long_short**.
  
  
              .. code-block:: python
  
                              long        short       long_short
                  date
                  2017-01-04  -0.001360   0.001394    0.000034
                  2017-01-05  0.002456    0.000058    0.002514
                  2017-01-06  0.000120    0.002739    0.002859
                  2017-01-09  0.001436    0.001838    0.003273
                  2017-01-10  0.000824    -0.001944   -0.001120
  
  
      :param show_notebook: Whether to display graphics in a notebook, default **True**.
          If True, show graph in notebook
          If False, return graph figure
      :return:
      """
      _figure_list = list(
          _get_risk_analysis_figure(analysis_df)
      ) + list(
          _get_monthly_risk_analysis_figure(
              report_normal_df,
              # report_long_short_df,
          )
      )
      if show_notebook:
          ScatterGraph.show_graph_in_notebook(_figure_list)
      else:
          return _figure_list
  
file_path: qlib/qlib/contrib/report/analysis_position/risk_analysis.py
imports: from typing import Iterable
  import pandas
  import plotly.graph_objs
  from ...evaluate import risk_analysis
  from ..graph import SubplotsGraph, ScatterGraph
label_desc: Use image node_id 7 for calling a global function with example usage: risk_analysis_graph(analysis_df, report_normal_df, report_long_short_df, show_notebook) and returns: _figure_list