From c29b813295b058cf958a8435d338903d214426c8 Mon Sep 17 00:00:00 2001 From: Juliette James Date: Wed, 28 Feb 2024 13:57:36 +0000 Subject: [PATCH 1/3] extended plot results to include savefig method --- qstrader/statistics/tearsheet.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qstrader/statistics/tearsheet.py b/qstrader/statistics/tearsheet.py index 9fced87..9e5d652 100644 --- a/qstrader/statistics/tearsheet.py +++ b/qstrader/statistics/tearsheet.py @@ -265,8 +265,6 @@ def plot_results(self, filename=None): """ Plot the Tearsheet """ - if settings.PRINT_EVENTS: - print('Plotting the tearsheet...') rc = { 'lines.linewidth': 1.0, 'axes.facecolor': '0.995', @@ -313,5 +311,14 @@ def plot_results(self, filename=None): # self._plot_txt_trade(stats, ax=ax_txt_trade) # self._plot_txt_time(stats, ax=ax_txt_time) + # Save the figure + if filename: + if settings.PRINT_EVENTS: + print(f"Saving tearsheet to {filename}") + fig = plt.gcf() + fig.savefig(filename) + # Plot the figure + if settings.PRINT_EVENTS: + print('Plotting the tearsheet...') plt.show() From d3c4be5b5960725f2dfb37637fe399ddc09e9d51 Mon Sep 17 00:00:00 2001 From: Juliette James Date: Wed, 28 Feb 2024 14:08:22 +0000 Subject: [PATCH 2/3] Added doc string to tearsheet.py plot_results --- qstrader/statistics/tearsheet.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qstrader/statistics/tearsheet.py b/qstrader/statistics/tearsheet.py index 9e5d652..6e9a66a 100644 --- a/qstrader/statistics/tearsheet.py +++ b/qstrader/statistics/tearsheet.py @@ -264,6 +264,11 @@ def format_perc(x, pos): def plot_results(self, filename=None): """ Plot the Tearsheet + + Parameters + ========== + filename : `str` + Option to save the tearsheet output when a filename is specified. """ rc = { 'lines.linewidth': 1.0, From d4c1abb48f7fb70b995f1bf2ac6c5875b0cd5275 Mon Sep 17 00:00:00 2001 From: Juliette James Date: Thu, 29 Feb 2024 10:01:41 +0000 Subject: [PATCH 3/3] Updated QSTrader to version 0.2.6 --- CHANGELOG.md | 6 ++++++ pyproject.toml | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a38b0d..8fc3f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.2.6 + +* Removed get_portfolio_total_non_cash_equity and get_account_total_non_cash_equity from broker/broker.py abstract base class. These methods are not implemented. +* Added save option to TearsheetStatistics class in statistics/tearsheet.py. The tearsheet output can now be saved to a given filename by passing the optional filename parameter as a string when calling the plot_results function. + + # 0.2.5 * Moved build-backend system to Hatchling from setuptools diff --git a/pyproject.toml b/pyproject.toml index 3469198..a735cba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,9 @@ build-backend = "hatchling.build" [project] name = "qstrader" -version = "0.2.5" +version = "0.2.6" dependencies = [ - "click>=8.0", + "click>=8.1", "matplotlib>=3.8", "numpy>=1.26", "pandas>=2.2",