From 9e92cb84d4282eb100d6e06ad626620b63866e67 Mon Sep 17 00:00:00 2001 From: Eric Ervin Date: Thu, 24 Dec 2020 06:05:29 -0800 Subject: [PATCH 1/4] update NumPy's dev workflow url --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db78bbb5..bf8d05c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,4 +62,4 @@ Please use explicit commit messages. See [NumPy's development workflow] for inspiration. [code-review]: https://mtlynch.io/code-review-love/ -[NumPy's development workflow]: https://docs.scipy.org/doc/numpy/dev/gitwash/development_workflow.html +[NumPy's development workflow]: https://numpy.org/doc/stable/dev/development_workflow.html From 9c0c613b4e94e4c762f97b7f69595983225faf76 Mon Sep 17 00:00:00 2001 From: Eric Ervin Date: Thu, 24 Dec 2020 08:46:35 -0800 Subject: [PATCH 2/4] modified legend visibility and created a test func --- backtesting/_plotting.py | 3 ++- backtesting/test/_test.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backtesting/_plotting.py b/backtesting/_plotting.py index 81044e44..0aa608a2 100644 --- a/backtesting/_plotting.py +++ b/backtesting/_plotting.py @@ -615,7 +615,8 @@ def __eq__(self, other): for f in plots: if f.legend: - f.legend.location = 'top_left' if show_legend else None + f.legend.visible = show_legend + f.legend.location = 'top_left' f.legend.border_line_width = 1 f.legend.border_line_color = '#333333' f.legend.padding = 5 diff --git a/backtesting/test/_test.py b/backtesting/test/_test.py index b45f9824..74cff577 100644 --- a/backtesting/test/_test.py +++ b/backtesting/test/_test.py @@ -642,6 +642,14 @@ def test_params(self): with self.subTest(param=p[0]): bt.plot(**dict([p]), filename=f, open_browser=False) + def test_hide_legend(self): + bt = Backtest(GOOG.iloc[:100], SmaCross) + bt.run() + with _tempfile() as f: + bt.plot(filename=f, show_legend=False) + # Give browser time to open before tempfile is removed + time.sleep(10) + def test_resolutions(self): with _tempfile() as f: for rule in 'LSTHDWM': From d6a0eb2c618c071f7ae0a1aa430fc27fadf27e38 Mon Sep 17 00:00:00 2001 From: Eric Ervin Date: Thu, 24 Dec 2020 09:20:00 -0800 Subject: [PATCH 3/4] fixed linting error --- backtesting/test/_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backtesting/test/_test.py b/backtesting/test/_test.py index 74cff577..db2b59a8 100644 --- a/backtesting/test/_test.py +++ b/backtesting/test/_test.py @@ -649,7 +649,7 @@ def test_hide_legend(self): bt.plot(filename=f, show_legend=False) # Give browser time to open before tempfile is removed time.sleep(10) - + def test_resolutions(self): with _tempfile() as f: for rule in 'LSTHDWM': From d54e8cfd6984c1b0ef1fb4f7d07212d175171d41 Mon Sep 17 00:00:00 2001 From: kernc Date: Thu, 24 Dec 2020 20:44:20 +0100 Subject: [PATCH 4/4] time.sleep(5) --- backtesting/test/_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backtesting/test/_test.py b/backtesting/test/_test.py index db2b59a8..ab905481 100644 --- a/backtesting/test/_test.py +++ b/backtesting/test/_test.py @@ -648,7 +648,7 @@ def test_hide_legend(self): with _tempfile() as f: bt.plot(filename=f, show_legend=False) # Give browser time to open before tempfile is removed - time.sleep(10) + time.sleep(5) def test_resolutions(self): with _tempfile() as f: