| 786 | time.sleep(1) |
| 787 | |
| 788 | def test_indicator_name(self): |
| 789 | test_self = self |
| 790 | |
| 791 | class S(Strategy): |
| 792 | def init(self): |
| 793 | def _SMA(): |
| 794 | return SMA(self.data.Close, 5), SMA(self.data.Close, 10) |
| 795 | |
| 796 | test_self.assertRaises(TypeError, self.I, _SMA, name=42) |
| 797 | test_self.assertRaises(ValueError, self.I, _SMA, name=("SMA One", )) |
| 798 | test_self.assertRaises( |
| 799 | ValueError, self.I, _SMA, name=("SMA One", "SMA Two", "SMA Three")) |
| 800 | |
| 801 | for overlay in (True, False): |
| 802 | self.I(SMA, self.data.Close, 5, overlay=overlay) |
| 803 | self.I(SMA, self.data.Close, 5, name="My SMA", overlay=overlay) |
| 804 | self.I(SMA, self.data.Close, 5, name=("My SMA", ), overlay=overlay) |
| 805 | self.I(_SMA, overlay=overlay) |
| 806 | self.I(_SMA, name="My SMA", overlay=overlay) |
| 807 | self.I(_SMA, name=("SMA One", "SMA Two"), overlay=overlay) |
| 808 | |
| 809 | def next(self): |
| 810 | pass |
| 811 | |
| 812 | bt = Backtest(GOOG, S) |
| 813 | bt.run() |
| 814 | with _tempfile() as f: |
| 815 | bt.plot(filename=f, |
| 816 | plot_drawdown=False, plot_equity=False, plot_pl=False, plot_volume=False, |
| 817 | open_browser=False) |
| 818 | |
| 819 | def test_indicator_color(self): |
| 820 | class S(Strategy): |