code: def treynor_ratio(self, benchmark, rf=0.02):
          
  
          benchmark = _try_to_squeeze(benchmark)
          if benchmark.ndim > 1:
              raise ValueError("Treynor ratio requires a single benchmark")
          rf = self._validate_rf(rf)
          beta = self.beta(benchmark)
          return (self.anlzd_ret() - rf) / beta
docs: Return over `rf` per unit of systematic risk.
  
          A measure of risk-adjusted performance that relates a
          portfolio's excess returns to the portfolio's beta.
          [Source: CFA Institute]
  
          Parameters
          ----------
          benchmark : {pd.Series, TSeries, 1d np.ndarray}
              The benchmark security to which `self` is compared.
          rf : {float, TSeries, pd.Series}, default 0.02
              If float, this represents an *compounded annualized*
              risk-free rate; 2.0% is the default.
              If a TSeries or pd.Series, this represents a time series
              of periodic returns to a risk-free security.
  
              To download a risk-free rate return series using
              3-month US T-bill yields, see:`pyfinance.datasets.load_rf`.
  
          Returns
          -------
          float