code: def perf_stats(
      returns,
      factor_returns=None,
      positions=None,
      transactions=None,
      turnover_denom="AGB",
  ):
      """
      Calculates various performance metrics of a strategy, for use in
      plotting.show_perf_stats.
  
      Parameters
      ----------
      returns : pd.Series
          Daily returns of the strategy, noncumulative.
           - See full explanation in tears.create_full_tear_sheet.
      factor_returns : pd.Series, optional
          Daily noncumulative returns of the benchmark factor to which betas are
          computed. Usually a benchmark such as market returns.
           - This is in the same style as returns.
           - If None, do not compute alpha, beta, and information ratio.
      positions : pd.DataFrame
          Daily net position values.
           - See full explanation in tears.create_full_tear_sheet.
      transactions : pd.DataFrame
          Prices and amounts of executed trades. One row per trade.
          - See full explanation in tears.create_full_tear_sheet.
      turnover_denom : str
          Either AGB or portfolio_value, default AGB.
          - See full explanation in txn.get_turnover.
  
      Returns
      -------
      pd.Series
          Performance metrics.
      """
  
      stats = pd.Series()
      for stat_func in SIMPLE_STAT_FUNCS:
          stats[STAT_FUNC_NAMES[stat_func.__name__]] = stat_func(
              returns
          )
  
      if positions is not None:
          stats["Gross leverage"] = gross_lev(positions).mean()
          if transactions is not None:
              stats["Daily turnover"] = get_turnover(
                  positions, transactions, turnover_denom
              ).mean()
      if factor_returns is not None:
          for stat_func in FACTOR_STAT_FUNCS:
              res = stat_func(returns, factor_returns)
              stats[STAT_FUNC_NAMES[stat_func.__name__]] = res
  
      return stats
  
imports: from __future__ import division
  from collections import OrderedDict
  from functools import partial
  import empyrical
  import numpy
  import pandas
  import scipy
  import scipy.stats
  from sklearn import linear_model
  from .deprecate import deprecated
  from .interesting_periods import PERIODS
  from .txn import get_turnover
  from .utils import APPROX_BDAYS_PER_MONTH, APPROX_BDAYS_PER_YEAR
  from .utils import DAILY
label_desc: Use image node_id 23 for calling a global function with example usage: perf_stats(returns, factor_returns, positions, transactions, turnover_denom) and returns: stats