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

Method test_method_sambo

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

Source from the content-addressed store, hash-verified

604 bt.plot(filename=f, open_browser=False)
605
606 def test_method_sambo(self):
607 bt = Backtest(GOOG.iloc[:100], SmaCross, finalize_trades=True)
608 res, heatmap, sambo_results = bt.optimize(
609 fast=range(2, 20), slow=np.arange(2, 20, dtype=object),
610 constraint=lambda p: p.fast < p.slow,
611 max_tries=30,
612 method='sambo',
613 return_optimization=True,
614 return_heatmap=True,
615 random_state=2)
616 self.assertIsInstance(res, pd.Series)
617 self.assertIsInstance(heatmap, pd.Series)
618 self.assertGreater(heatmap.max(), 1.1)
619 self.assertGreater(heatmap.min(), -2)
620 self.assertEqual(-sambo_results.fun, heatmap.max())
621 self.assertEqual(heatmap.index.tolist(), heatmap.dropna().index.unique().tolist())
622
623 def test_max_tries(self):
624 bt = Backtest(GOOG.iloc[:100], SmaCross)

Callers

nothing calls this directly

Calls 2

optimizeMethod · 0.95
BacktestClass · 0.90

Tested by

no test coverage detected