Skip to content

Commit c370f42

Browse files
Qs625 update qst (#391)
* extended plot results to include savefig method * Added doc string to tearsheet.py plot_results * Updated QSTrader to version 0.2.6
1 parent be5109c commit c370f42

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.2.6
2+
3+
* 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.
4+
* 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.
5+
6+
17
# 0.2.5
28

39
* Moved build-backend system to Hatchling from setuptools

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "qstrader"
7-
version = "0.2.5"
7+
version = "0.2.6"
88
dependencies = [
9-
"click>=8.0",
9+
"click>=8.1",
1010
"matplotlib>=3.8",
1111
"numpy>=1.26",
1212
"pandas>=2.2",

qstrader/statistics/tearsheet.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,12 @@ def format_perc(x, pos):
264264
def plot_results(self, filename=None):
265265
"""
266266
Plot the Tearsheet
267+
268+
Parameters
269+
==========
270+
filename : `str`
271+
Option to save the tearsheet output when a filename is specified.
267272
"""
268-
if settings.PRINT_EVENTS:
269-
print('Plotting the tearsheet...')
270273
rc = {
271274
'lines.linewidth': 1.0,
272275
'axes.facecolor': '0.995',
@@ -313,5 +316,14 @@ def plot_results(self, filename=None):
313316
# self._plot_txt_trade(stats, ax=ax_txt_trade)
314317
# self._plot_txt_time(stats, ax=ax_txt_time)
315318

319+
# Save the figure
320+
if filename:
321+
if settings.PRINT_EVENTS:
322+
print(f"Saving tearsheet to {filename}")
323+
fig = plt.gcf()
324+
fig.savefig(filename)
325+
316326
# Plot the figure
327+
if settings.PRINT_EVENTS:
328+
print('Plotting the tearsheet...')
317329
plt.show()

0 commit comments

Comments
 (0)