code: def calc_information_ratio(returns, benchmark_returns):
      
      diff_rets = returns - benchmark_returns
      diff_std = np.std(diff_rets, ddof=1)
  
      if np.isnan(diff_std) or diff_std == 0:
          return 0.0
  
      return np.divide(diff_rets.mean(), diff_std)
docs: Calculates the `Information ratio <https://www.investopedia.com/terms/i/informationratio.asp>`_ (or `from Wikipedia <http://en.wikipedia.org/wiki/Information_ratio>`_).