(self)
| 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 | |
| 984 | class TestUtil(TestCase): |
nothing calls this directly
no test coverage detected