code: def test_calc_sortino_ratio(df):
      rf = 0
      p = 1
      r = df.to_returns()
      a = r.calc_sortino_ratio(rf=rf, nperiods=p)
      er = r.to_excess_returns(rf, p)
      negative_returns = np.minimum(er[1:], 0)
      assert np.allclose(
          a,
          np.divide((er.mean() - rf), np.std(negative_returns, ddof=1))
          * np.sqrt(p),
      )
  
imports: import ffn
  import pandas
  import numpy
  from pytest import fixture
  from numpy.testing import assert_almost_equal
label_desc: Use image node_id 34 for calling a global function with example usage: test_calc_sortino_ratio(df) without return types