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

Reporting: Have you considered generating HTML instead of PDF, or as a preliminary to #802

Open
robcarver17 opened this issue Oct 11, 2022 · 0 comments

Comments

@robcarver17
Copy link
Owner

  Have you considered generating HTML instead of PDF, or as a preliminary to

it?

One benefit of HTML is that you could include charts in the emailed
reports, and mixing text and images is of course not a problem. You could
always email a PDF file, but an email with images seems nicer.

Github.com can also display html files.

There are libraries available to convert HTML to PDF if you still want PDF
for some reason (although I know you don't like adding dependencies).

On Tue, Jul 12, 2022 at 7:30 AM Robert Carver @.***>
wrote:

It would be nice to have the option to output reports into a .pdf file.
That way, figures can be plotted. The use case I'm thinking of is issue
#653 #653 but
clearly one could use this for accounting p&l as well.

A quick check reveals that github.com can render .pdf so that is good.

The following code fragment seems the easiest way of generating .pdf files
consisting of multiple plots (from
https://datatofish.com/export-matplotlib-pdf/)

from matplotlib.backends.backend_pdf import PdfPages
Data1 = {'Unemployment_Rate': [6.1,5.8,5.7,5.7,5.8,5.6,5.5,5.3,5.2,5.2],
'Stock_Index_Price': [1500,1520,1525,1523,1515,1540,1545,1560,1555,1565]
}
df1 = DataFrame(Data1,columns=['Unemployment_Rate','Stock_Index_Price'])

with PdfPages(r'C:\Users\Ron\Desktop\Charts.pdf') as export_pdf:

plt.scatter(df1['Unemployment_Rate'], df1['Stock_Index_Price'], color='green')
plt.title('Unemployment Rate Vs Stock Index Price', fontsize=10)
plt.xlabel('Unemployment Rate', fontsize=8)
plt.ylabel('Stock Index Price', fontsize=8)
plt.grid(True)
export_pdf.savefig()
plt.close()

It also works on a headless terminal (checked).

It would be nice to include text as well, but let's park that for the
moment (can always be a seperate file).

Now, this does not fit well into the paradigm used by the reporting code
in psystemtrade. Remember, we generate a list of special objects (headers,
body_text, table) which is then 'parsed' into a single text string, which
we then email or dump to file etc.

MORE TBC


Reply to this email directly, view it on GitHub
#680, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AA3JWKVKH5NKN5EXDNF3XT3VTV6RPANCNFSM53LH7BPQ
.
You are receiving this because you are subscribed to this thread.Message
ID: @.***>

Originally posted by @tgibson11 in #680 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant