code: def perf_stats(returns, factor_returns=None, positions=None,
                 transactions=None, turnover_denom='AGB'):
      
  
      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
docs: 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.