quantopian / pyfolio

Portfolio and risk analytics in Python
https://quantopian.github.io/pyfolio
Apache License 2.0
5.62k stars 1.77k forks source link

Use of jinja2 to create PDFs of tear sheets #594

Open trical09 opened 5 years ago

trical09 commented 5 years ago

Has jinja ever been considered for creating PDF versions of the tear sheets? I use tear sheets as reports that I can then save to file as records. I can distribute them, print them out, and reference them later. This ability to use a tear sheet as a document is really valuable to me. I know that pyfolio features the ability to produce a tear sheet as a matplotlib fig or as a part of a Jupyter notebook, which can then be turned into a PDF. It seems like the most straightforward way to make a tear sheet that one could automatically generate and store as a report would be to create a report specifically designed to be viewed in a standard US Letter or A4 format.

One can do this using jinja2 and an HTML to PDF library such as weasyprint. The process involves:

Thoughts / interest?

Netherdrake commented 5 years ago

Is there any way to get the pyfolio output as HTML currently?

trical09 commented 5 years ago

I believe the only way to do this at this time would be to somehow convert a matplotlib fig to an image with an HTML wrapper file. There may be a utility to do this.