Report writers
PortfolioOptimisers.write_report — Function
write_report(path::AbstractString, r::Report; format::Option{<:MIME} = nothing,
figure_mime::MIME = MIME"image/svg+xml"()) -> StringWrite a Portfolio Report to a file, as Markdown or as one self-contained HTML file.
The format comes from the extension of path when format is nothing: .md for Markdown, .html or .htm for HTML. The figures are SVG images by default. An SVG image holds every point of its series, so a report of many entries with daily series over many years can be large. figure_mime = MIME"image/png"() gives raster images, which have a size that does not grow with the series. A figure that cannot show itself in the chosen MIME takes the other image MIME. show(io, MIME"text/html"(), r) writes the same bytes as this function with the default figure_mime.
Arguments
path: The path of the file.r: The report.format: The MIME of the format,MIME"text/markdown"()orMIME"text/html"(), ornothing.figure_mime: The image MIME of the figures,MIME"image/svg+xml"()orMIME"image/png"().
Validation
- The rules of
report_format. figure_mimeisimage/svg+xmlorimage/png. Otherwise the function raises anArgumentError.
Returns
path::String: The path of the file.
Related
Base.show — Method
Base.show(io::IO, mime::MIME"text/markdown", b::AbstractReportBlock)
Base.show(io::IO, mime::MIME"text/markdown", e::ReportEntry)
Base.show(io::IO, mime::MIME"text/markdown", r::Report)Write a block, an entry or a Portfolio Report as Markdown.
A section, an entry and a report write a heading, and each writes its blocks one level below it. A table is a pipe table with its caption in italics above it, and a figure is an image with a data URI. A Markdown viewer that does not read a data URI shows the caption of the figure. Every string of the caller passes through md_escape. The text of a number in a table does not, because the writer makes that text and it holds no markup.
Arguments
io: The stream.mime: The MIMEtext/markdown.b,e,r: The block, the entry or the report.
Returns
nothing.
Related
Base.show — Method
Base.show(io::IO, mime::MIME"text/html", b::AbstractReportBlock)
Base.show(io::IO, mime::MIME"text/html", e::ReportEntry)
Base.show(io::IO, mime::MIME"text/html", r::Report)Write a block or an entry as an HTML fragment, or a Portfolio Report as one self-contained HTML file.
The file of a report holds its style, its script and its figures inline, and loads nothing. A Content Security Policy, REPORT_CSP, makes the browser refuse any load from the network. Every string of the caller passes through html_escape. The file shows one entry at a time when its script runs, with a selector when the report holds more than one entry, a filter when an entry has a group, and a toggle of the theme. With no script, and in print, the file shows every entry.
Arguments
io: The stream.mime: The MIMEtext/html.b,e,r: The block, the entry or the report.
Returns
nothing.
Related