Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qs625 update qst #391

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 14 additions & 2 deletions qstrader/statistics/tearsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,12 @@ 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.
"""
if settings.PRINT_EVENTS:
print('Plotting the tearsheet...')
rc = {
'lines.linewidth': 1.0,
'axes.facecolor': '0.995',
Expand Down Expand Up @@ -313,5 +316,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()