MCPcopy Create free account
hub / github.com/kernc/backtesting.py / test_resample_apply

Method test_resample_apply

backtesting/test/_test.py:875–894  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

873 self.assertEqual(quantile(np.r_[1, 3, 2]), .5)
874
875 def test_resample_apply(self):
876 res = resample_apply('D', SMA, EURUSD.Close, 10)
877 self.assertEqual(res.name, 'C[D]')
878 self.assertEqual(res.count() / res.size, .9634)
879 np.testing.assert_almost_equal(res.iloc[-48:].unique().tolist(),
880 [1.242643, 1.242381, 1.242275],
881 decimal=6)
882
883 def resets_index(*args):
884 return pd.Series(SMA(*args).values)
885
886 res2 = resample_apply('D', resets_index, EURUSD.Close, 10)
887 self.assertTrue((res.dropna() == res2.dropna()).all())
888 self.assertTrue((res.index == res2.index).all())
889
890 res3 = resample_apply('D', None, EURUSD)
891 self.assertIn('Volume', res3)
892
893 res3 = resample_apply('D', lambda df: (df.Close, df.Close), EURUSD)
894 self.assertIsInstance(res3, pd.DataFrame)
895
896 def test_plot_heatmaps(self):
897 bt = Backtest(GOOG, SmaCross)

Callers

nothing calls this directly

Calls 1

resample_applyFunction · 0.90

Tested by

no test coverage detected