MCPcopy Index your code
hub / github.com/kernc/backtesting.py / test_MultiBacktest

Method test_MultiBacktest

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

Source from the content-addressed store, hash-verified

964 self.assertAlmostEqual(stats['_strategy']._indicators[0][trade['EntryBar']], 234.14)
965
966 def test_MultiBacktest(self):
967 import backtesting
968 assert callable(getattr(backtesting, 'Pool', None)), backtesting.__dict__
969 for start_method in mp.get_all_start_methods():
970 with self.subTest(start_method=start_method), \
971 patch(backtesting, 'Pool', mp.get_context(start_method).Pool):
972 start_time = time.monotonic()
973 btm = MultiBacktest([GOOG, EURUSD, BTCUSD], SmaCross, cash=100_000)
974 res = btm.run(fast=2)
975 self.assertIsInstance(res, pd.DataFrame)
976 self.assertEqual(res.columns.tolist(), [0, 1, 2])
977 heatmap = btm.optimize(fast=[2, 4], slow=[10, 20])
978 self.assertIsInstance(heatmap, pd.DataFrame)
979 self.assertEqual(heatmap.columns.tolist(), [0, 1, 2])
980 print(start_method, time.monotonic() - start_time)
981 plot_heatmaps(heatmap.mean(axis=1), open_browser=False)
982
983
984class TestUtil(TestCase):

Callers

nothing calls this directly

Calls 5

runMethod · 0.95
optimizeMethod · 0.95
patchFunction · 0.90
MultiBacktestClass · 0.90
plot_heatmapsFunction · 0.90

Tested by

no test coverage detected