macrosynergy.pnl.pnl_table#
Presentation-ready HTML rendering of NaivePnL.evaluate_pnls() statistics
as a grouped, ledger-style table for reports and notebooks.
- class HTMLTable(data)[source]#
Bases:
objectThe HTML table returned by
NaivePnL.evaluate_pnls_html().Displays as a formatted table when returned as the last line of a notebook cell. The raw HTML is available as
.data, e.g. to save it to a file withPath("table.html").write_text(table.data).
- pnl_table_html(tbr, groups, headlines, bench, headline_labels, bench_label, whole_number_metrics=(), plus_prefix=None, negative_share_row=None, footnotes=True, title='Naive PnL statistics', subtitle='', custom_css=None)[source]#
Render a grouped, ledger-style HTML table from an already-computed
evaluate_pnls()statistics DataFrame. All headline (strategy) columns share one style; all benchmark columns are shown in a distinct, muted style.- Parameters:
tbr (pd.DataFrame) – Output of
evaluate_pnls()(or a renamed copy of it), indexed by metric name, columns are PnL categories.groups (list of (section title, [metric names])) – Row layout and order. Every metric referenced must be a row in
tbr.headlines (list of str) –
tbrcolumns to show as the (non-benchmark) strategy columns, in display order.bench (str or list of str) –
tbrcolumn(s) to show as the benchmark (muted) column(s), in display order.headline_labels (list of str, str or list of str) – Column header labels, matching
headlines1:1, andbench1:1 (a bare str is only valid whenbenchis a single column).bench_label (list of str, str or list of str) – Column header labels, matching
headlines1:1, andbench1:1 (a bare str is only valid whenbenchis a single column).whole_number_metrics (sequence of str, default ()) – Metric names formatted with no decimal places (e.g. “Traded Months”) instead of two.
plus_prefix (dict of {row name: [column names]}, optional) – Cells to prefix with “+” (e.g. an unrecovered drawdown still in progress). A footnote explaining the “+” is appended below the table whenever this marks at least one cell (subject to
footnotes).negative_share_row (str, optional) – Row name to check for negative values (e.g. “Top 5% Monthly PnL Share”, which reads negative whenever total PnL is negative, since it’s top-5%-months PnL divided by total PnL). A footnote explaining this is appended below the table whenever that row has a negative cell (subject to
footnotes).footnotes (bool, default True) – Whether to render the explanatory footnotes above (for “+” and/or
negative_share_row) at all. The underlying “+” prefix on cells is unaffected - this only toggles the footnote text.title (str) – Header text shown above the table.
subtitle (str) – Header text shown above the table.
custom_css (str, optional) –
Raw CSS injected in a second
<style>block, right after the table’s own default stylesheet - same-specificity selectors win by source order, so rules targeting the classes below override the defaults without needing!important:.pnl-wrap- outer container (font, border, background). Sizes to fit its content (width:fit-content) between a 640px minimum and its embedding page’s width as a maximum, so extra columns or long labels widen the box rather than being clipped or forcing a scrollbar - keeping the whole table selectable in one paste, e.g. into Word..pnl-title,.pnl-subtitle- header text above the table.pnl-table- the<table>element itself.pnl-thead-row,.pnl-th-corner,.pnl-th- header row background and column-header cells.pnl-group-cell- section title bars (e.g. “Risk & drawdown”).pnl-row-even,.pnl-row-odd- zebra-striped data rows.pnl-label- the metric-name cell of a data row.pnl-value,.pnl-value-strategy,.pnl-value-bench- numeric cells; the latter two color strategy vs. benchmark columns differently.pnl-num,.pnl-num-split,.pnl-num-int,.pnl-num-frac- decimal-point alignment of the numbers themselves.pnl-footnote- the “+”/negative-share explanation footnotes, if shown
- Returns:
A self-contained HTML string.
- Return type: