code: def sharpe_ratio(returns,
                   risk_free=0,
                   period=DAILY,
                   annualization=None,
                   out=None):
      
      allocated_output = out is None
      if allocated_output:
          out = np.empty(returns.shape[1:])
  
      return_1d = returns.ndim == 1
  
      if len(returns) < 2:
          out[()] = np.nan
          if return_1d:
              out = out.item()
          return out
  
      returns_risk_adj = np.asanyarray(_adjust_returns(returns, risk_free))
      ann_factor = annualization_factor(period, annualization)
  
      np.multiply(
          np.divide(
              nanmean(returns_risk_adj, axis=0),
              nanstd(returns_risk_adj, ddof=1, axis=0),
              out=out,
          ),
          np.sqrt(ann_factor),
          out=out,
      )
      if return_1d:
          out = out.item()
  
      return out
docs: Determines the Sharpe ratio of a strategy.
  
      Parameters
      ----------
      returns : pd.Series or np.ndarray
          Daily returns of the strategy, noncumulative.
          - See full explanation in :func:`~empyrical.stats.cum_returns`.
      risk_free : int, float
          Constant risk-free return throughout the period.
      period : str, optional
          Defines the periodicity of the 'returns' data for purposes of
          annualizing. Value ignored if `annualization` parameter is specified.
          Defaults are::
  
              'monthly':12
              'weekly': 52
              'daily': 252
  
      annualization : int, optional
          Used to suppress default values available in `period` to convert
          returns into annual returns. Value should be the annual frequency of
          `returns`.
      out : array-like, optional
          Array to use as output buffer.
          If not passed, a new array will be created.
  
      Returns
      -------
      sharpe_ratio : float
          nan if insufficient length of returns or if if adjusted returns are 0.
  
      Note
      -----
      See https://en.wikipedia.org/wiki/Sharpe_ratio for more details.