Output Handlers#
Output handlers write the results of a run, apart from the attribution itself, just as input
handlers read its inputs. main() passes every run’s AttributionResult to its output handlers
before it plots or serves the dashboard: by default an ExcelOutputHandler built from the
configuration, which writes the Excel report. main(..., output_handlers=[...])
replaces that list, and output_handlers=() writes nothing. A handler of your own subclasses
OutputHandlerInterface and implements output_result(*, result).
Abstract base class interface for writing the results of an attribution run.
This module defines the contract that every output handler implements, so the attribution never depends on how or where its results are written (an Excel report today; other formats can be added as handlers of their own).
- class OutputHandlerInterface[source]#
Bases:
objectAbstract base class for output handlers.
main()passes the result of every run to its output handlers, in order, once the attribution is done and before it plots or serves the dashboard. A handler receives its destination and options when it is built, not from the run, so it writes a file-based result and an in-memory one (run_attribution_from_backtest()) alike. A handler only reads the result: it never changes a number.- abstractmethod output_result(*, result: AttributionResult) Path[source]#
Write result and return where it was written.
- Parameters:
result (AttributionResult) – The run’s result; only read.
- Returns:
The file (or directory) written.
- Return type:
Path
Excel output handler: writes the Excel report of an attribution result.
The workbook itself is built by
write_excel_report();
this handler carries where to write it and how to name it, so main() can
write it like any other output.
- class ExcelOutputHandler(output_directory: str | PathLike[str], *, name: str = 'Portfolio', benchmark_name: str | None = None)[source]#
Bases:
OutputHandlerInterfaceWrites the Excel report of a result to a directory.
The handler
main()uses when it is given no output handlers (seefrom_configuration()).- Parameters:
output_directory (str or os.PathLike) – Directory the workbook is written to; created when missing.
name (str, default "Portfolio") – Report name: the summary’s title and the start of the file name.
benchmark_name (str or None, default None) – Shown in the summary’s info block when given.
- Variables:
output_directory (str or os.PathLike)
name (str)
benchmark_name (str or None)
- classmethod from_configuration(configuration: Configuration) Self[source]#
The handler of a file-based run: its
output_directory, named after its portfolio file.- Parameters:
configuration (Configuration) – Supplies
output_directory,portfolio_file_name(the report name) andbenchmark_file_name(the benchmark shown).- Returns:
The handler
main()uses by default.- Return type:
- output_result(*, result: AttributionResult) Path[source]#
Write the Excel report of result and return the workbook’s path.
- Parameters:
result (AttributionResult) – The run’s result; only read.
- Returns:
{name}_{UTC %Y%m%d%H%M%S}_attribution_results.xlsxinoutput_directory(seewrite_excel_report()).- Return type:
Path
- Raises:
OSError – If the directory or the workbook cannot be written.
Excel report#
write_excel_report() builds the workbook the Excel handler writes. It is also exported from the
package root (from kaxanuk.attribution_analysis import write_excel_report).
Excel report of an attribution run.
write_excel_report() writes an AttributionResult to one workbook,
in the style of the KaxaNuk Backtest Engine’s Excel report so that a backtest
and its attribution read alike, and laid out the way professional attribution
reports are (headline figures first, active risk next to active return, a row
per calendar year, a bridge from benchmark to portfolio, the methodology
disclosed):
summary: the headline figures (portfolio, benchmark and active return, tracking error, information ratio, maximum drawdown), the window and the methods; key findings in plain English, generated from the numbers; the headline tables, including attribution by calendar year and the factors grouped into style and industry; four native Excel charts (the bridge from benchmark to portfolio return, the cumulative portfolio and benchmark return, the cumulative effects over time, the contribution per factor); and a table of contents.checks: the run’s parameters, how the numbers were computed and every diagnostic it logged (AttributionResult.diagnostics).how_to_read: what each effect and term means, and what each sheet holds.One data sheet per result table, as an Excel table with filters: Brinson-Fachler
per_period,cumulativeandby_year; the factor model’s tables; the active factor model’s and theimplementationtable when present. Brinson-Fachlerdetailsare not written: dates x groups can exceed Excel’s 1,048,576 rows.chart_data(hidden): the values the bridge and the factor charts draw.
It reads the result only and recomputes no attribution number: the summary
shows values of the result tables (the last row of a cumulative table, a row of
a by-year table, a share of cumulative_shares, a statistic). The report adds
only presentation sums, each labelled: the factor groups’ subtotals, selection
plus interaction, the bridge’s residual, and the implementation block (engine and
holdings returns compounded, costs summed). Nothing but the workbook is written:
the charts are native, not images. Every word comes from
excel_report_text.
- FILE_NAME_SUFFIX = 'attribution_results'#
The workbook is
{name}_{UTC %Y%m%d%H%M%S}_attribution_results.xlsx.
- STATISTIC_FORMATS = {'Annualized Return': '0.00%', 'Annualized Vol': '0.00%', 'Cornish-Fisher VaR (5%)': '0.00%', 'Historic CVaR (5%)': '0.00%', 'Kurtosis': '0.0000', 'Max Drawdown': '0.00%', 'Sharpe Ratio': '0.0000', 'Skewness': '0.0000', 'Total Return': '0.00%'}#
Number format of each
summary_statskey; a key not listed is written withRATIO_FORMAT.
- write_excel_report(result: AttributionResult, output_directory: str | PathLike[str], *, name: str = 'Portfolio', benchmark_name: str | None = None) Path[source]#
Write the attribution result to an Excel workbook and return its path.
The workbook is
{name}_{UTC %Y%m%d%H%M%S}_attribution_results.xlsxin output_directory, which is created when missing. An existing file is never overwritten: a second report in the same second gets_2before the extension, and so on. Nothing else is written, and a workbook that fails while being saved is removed.- Parameters:
result (AttributionResult) – What
run_attribution(),mainorrun_attribution_from_backtest()returned. It is only read.output_directory (str or os.PathLike) – Directory the workbook is written to.
name (str, default "Portfolio") – Report name: the summary’s title and the start of the file name (characters a file name cannot hold become
_).benchmark_name (str or None, default None) – Shown in the summary’s info block when given.
- Returns:
The workbook written.
- Return type:
Path
- Raises:
FileExistsError – If 100 report files of the same name and second already exist.
OSError – If the directory or the file cannot be written.
Report text#
Every word of the report lives in one module, so a report in another language is a translation of it, not a change to the builder.
Every user-facing string of the Excel attribution report, in English.
excel_report builds the workbook and
takes all of its words from here: sheet names, titles, column labels, the key
findings, the checks, the methodology notes and the definitions. A report in
another language is a translation of this module (the same names and the same
str.format fields), not a change to the builder.
Templates are str.format strings. Their fields are numbers (formatted here,
e.g. {active:+.2%}), dates ({start:%Y-%m-%d}) or text the builder takes
from the other mappings of this module.
- CHART_DATA_HEADERS = ('Bar', 'Value', 'Base above zero', 'Base below zero', 'Gain above zero', 'Gain below zero', 'Loss above zero', 'Loss below zero', 'Total above zero', 'Total below zero')#
the bar, its value, then the stacked series that draw it.
- Type:
Columns of the bridge chart’s data
- CHART_FACTOR_HEADERS = ('Factor', 'Contribution')#
Columns of the factor chart’s data.
- COLUMN_LABELS = mappingproxy({'date': 'Date', 'year': 'Year', 'portfolio_returns': 'Portfolio return', 'benchmark_returns': 'Benchmark return', 'alpha': 'Active return', 'active_returns': 'Active return', 'allocation': 'Allocation', 'selection': 'Selection', 'interaction': 'Interaction', 'factor_returns': 'All factors', 'carry_returns': 'Carry', 'dividends_returns': 'Dividends', 'idiosyncratic_returns': 'Idiosyncratic', 'f_carry': 'Carry', 'f_dividends': 'Dividends', 'f_idio_returns': 'Idiosyncratic', 'idio_returns': 'Idiosyncratic', 'engine_returns': 'Engine NAV return', 'holdings_returns': 'Holdings return', 'commissions': 'Commissions', 'slippage': 'Slippage', 'financing': 'Financing', 'execution': 'Execution', 'factor': 'Factor', 'share': 'Share of return'})#
Header of each known result column; a factor column takes
FACTOR_LABELS, or its file’s name withoutf_.
- DEFINITIONS = (('Active return', 'The portfolio return minus the benchmark return. Brinson-Fachler splits it into allocation, selection and interaction; the active factor model splits it into factors and a residual.'), ('Allocation', "The part of the active return earned by weighting segments differently from the benchmark: overweighting segments that beat the benchmark's total return and underweighting those that lagged it. Per segment: (portfolio weight - benchmark weight) x (segment benchmark return - total benchmark return)."), ('Selection', "The part earned by holding better names inside each segment: benchmark weight x (segment portfolio return - segment benchmark return). Without a segment map every ticker is its own segment, so a segment's portfolio and benchmark returns are the same ticker's: selection and interaction are then zero and the whole active return is allocation."), ('Interaction', "The joint effect of weighting and picking: (portfolio weight - benchmark weight) x (segment portfolio return - segment benchmark return). It is not a decision of its own; many managers report it inside selection, which the 'Selection incl. interaction' subtotal does."), ('Bridge chart', "Starts at the benchmark's cumulative return, adds allocation, selection and interaction (and any residual) and ends at the portfolio's: the bars between the two totals are the active return."), ('Calendar years', "Each year is linked on its own dates, so its effects add up to that year's active return. Years compound into the whole window: they do not add up to it, and cumulative figures over many years can look counterintuitive next to them."), ('Tracking error', 'How much the active return varies: the standard deviation of the daily active returns, annualized (x the square root of 252).'), ('Information ratio', 'Active return per unit of active risk: the mean daily active return over its standard deviation, annualized. Above about 0.5 sustained over years is considered good.'), ('Beta', 'How much the portfolio moves when the benchmark moves 1%: above 1 it moves more, below 1 less.'), ('Hit rate', 'The share of days on which the portfolio beat the benchmark.'), ('Factor contribution', "A factor's part of the portfolio return: the portfolio-weighted sum, over the holdings, of each holding's exposure times the factor return (each factor file holds those per-holding values). Style factors (market, size, momentum, beta, volatility, value) and industry factors are grouped apart."), ('Idiosyncratic residual', 'What the factors leave unexplained: the portfolio return minus every factor contribution (and the carry and dividend components, when given). It is not proof of skill: another factor model can split the same return differently.'), ('Return components', 'Carry (f_carry) and dividends (f_dividends) files are contributions of their own, not factors: they are reported separately and taken out of the residual.'), ('Share of return', "A contribution divided by the cumulative portfolio return. The shares add up to 100%; when that return is small, or the parts have opposite signs, a share can exceed 100% or be negative. 'n/m' (not meaningful) replaces them when the return is under 1% in size or a share would exceed 200%."), ('Linking: Carino', "Daily effects do not add up to a compounded return over many days. Carino (1999) scales each day's effects with logarithmic coefficients so the cumulative effects add up exactly to the compounded return difference, whatever the order of the days."), ('Linking: GRAP', "GRAP (1997) also makes the cumulative effects add up exactly: each day's effect grows at the portfolio return of the days before it and at the benchmark return of the days after it, so it depends on their order."), ('Linking: none', 'No linking: cumulative effects are plain running sums of the daily effects. They add up to the sum of the daily returns, not to the compounded return. Legacy Brinson-Fachler is never linked.'), ('Active factor model', "The factor model run twice, on the portfolio and on the benchmark's holdings: each factor's active contribution is the portfolio's minus the benchmark's, and the active residual is what the factors leave of the active return."), ('Holdings benchmark', 'The benchmark built from the benchmark weights and the asset prices, which Brinson-Fachler and the active factor model attribute against. It is checked against the reported benchmark returns: a difference above 1 bp on any date is a warning on the checks sheet.'), ('Implementation', "Backtest Engine runs only: the engine's NAV return per date, split into the return of the holdings (what is attributed) plus commissions, slippage, financing and execution. Costs are negative returns, as fractions of the previous NAV. Backtest results are hypothetical."), ('Annualized figures', 'Annualized return and volatility assume 252 return dates a year. The total return is compounded over the dates with a portfolio return.'), ('VaR and CVaR', 'Daily losses, shown as positive numbers: the Cornish-Fisher VaR (5%) is the loss exceeded on 5% of days, adjusted for skewness and kurtosis; the historic CVaR (5%) is the average loss on the worst 5% of days.'), ('Colours and signs', 'Effects and contributions carry their sign (+ or -); blue marks a gain and vermilion a loss, colours chosen to read with any colour vision.'))#
Term and meaning pairs of the how-to-read sheet, in reading order.
- DIAGNOSTIC_AREAS = mappingproxy({'benchmark_weights_ignored': 'Inputs', 'cash_price_file_ignored': 'Inputs', 'end_date_after_data': 'Inputs', 'brinson_fachler_legacy_formula': 'Brinson-Fachler', 'brinson_fachler_legacy_not_linked': 'Brinson-Fachler', 'brinson_fachler_substituted_group_dates': 'Brinson-Fachler', 'brinson_fachler_unpriced_group_dates': 'Brinson-Fachler', 'brinson_fachler_weight_dates_without_prices': 'Brinson-Fachler', 'segment_unpriced_holdings': 'Brinson-Fachler', 'benchmark_check_bad_return_columns': 'Benchmark check', 'benchmark_check_no_common_dates': 'Benchmark check', 'benchmark_check_without_returns': 'Benchmark check', 'benchmark_returns_differ': 'Benchmark check', 'factor_dates_without_factor_attribution': 'Factor model', 'factor_dates_without_portfolio_return': 'Factor model', 'factor_weight_rows_without_date': 'Factor model', 'active_dates_excluded': 'Active factor model', 'active_unpriced_holdings': 'Active factor model', 'active_weight_sums': 'Active factor model', 'summary_statistics_skipped': 'Summary statistics'})#
Area of each diagnostic code; an unknown code shows
UNKNOWN_AREA.
- DIAGNOSTIC_TEXTS = mappingproxy({'benchmark_weights_ignored': 'Benchmark weights were passed but not used: Brinson-Fachler and the active factor model were off.', 'cash_price_file_ignored': 'The price file {price_file} was ignored: with the textbook formula the cash ticker {cash_ticker} earns 0.', 'end_date_after_data': 'The end date {end_date} is after the last date of {source} ({latest_date}); its data was used up to that date.', 'brinson_fachler_legacy_formula': 'Brinson-Fachler ran with the deprecated legacy formula, which reproduces the numbers of 0.3.x and earlier. Switch to textbook.', 'brinson_fachler_legacy_not_linked': 'Legacy Brinson-Fachler is never linked: its cumulative effects are running sums, whatever the linking method ({linking_method}).', 'brinson_fachler_substituted_group_dates': "{count} group-dates held weight on one side but had no return there; the other side's return was used, so no selection was credited.", 'brinson_fachler_unpriced_group_dates': '{count} weighted group-dates had no return on either side and counted as 0.', 'brinson_fachler_weight_dates_without_prices': '{count} {side} weight dates have no price row (first {first_date}) and were left out of Brinson-Fachler.', 'segment_unpriced_holdings': '{count} held ticker-dates have no return and counted as 0 in their segment (first: {ticker} on {first_date}).', 'benchmark_check_bad_return_columns': 'The benchmark cross-check was skipped: the benchmark returns have {count} return columns instead of one.', 'benchmark_check_no_common_dates': 'The benchmark cross-check was skipped: no date has both a holdings and a reported benchmark return.', 'benchmark_check_without_returns': 'No benchmark returns were given, so the benchmark built from the benchmark weights was not compared with a reported benchmark return.', 'benchmark_returns_differ': 'The benchmark built from the benchmark weights differs from the reported benchmark return by more than {tolerance:.2%} on {count} of {total} dates (largest {largest_difference:.4%}). Check that the weights cover the whole benchmark and that their prices match the index.', 'factor_dates_without_factor_attribution': "{count} dates with a portfolio return have no factor attribution (first {first_date}): they are left out of the factor contributions, shares and totals, so the factor model's cumulative return differs from the portfolio's own.", 'factor_dates_without_portfolio_return': '{count} factor-model dates have no {side} return (first {first_date}) and are left out of the cumulative contributions, totals and shares.', 'factor_weight_rows_without_date': '{count} {side} weight rows have no date and were not attributed by the factor model.', 'active_dates_excluded': '{count} of {total} dates with a portfolio return have no benchmark return or benchmark factor data and are left out of the active factor model.', 'active_unpriced_holdings': '{count} weighted {side} ticker-dates have no return and counted as 0 in the active factor model (first: {ticker} on {first_date}).', 'active_weight_sums': 'The net {side} weights differ from 1 on {count} of {total} dates (first {first_date}, sum {first_sum:.6f}); the difference lands in the active effects.', 'summary_statistics_skipped': 'No date has a portfolio return, so the summary statistics were not computed.'})#
What happened, per diagnostic code; an unknown code shows the logged line instead.
- EXPECTED_DIAGNOSTIC_TEXTS = mappingproxy({'factor_dates_without_portfolio_return': 'The first date of the window ({first_date}) has no return, since there is no earlier price to measure it from, so it is left out. This is expected.'})#
What happened, for the diagnostics every run of this kind logs (the level reads
expected).
- FACTOR_LABELS = mappingproxy({'f_market': 'Market', 'f_size': 'Size', 'f_momentum': 'Momentum', 'f_beta': 'Beta', 'f_residual volatility': 'Residual volatility', 'f_value': 'Value', 'f_Communication Services': 'Communication Services', 'f_Consumer Discretionary': 'Consumer Discretionary', 'f_Consumer Staples': 'Consumer Staples', 'f_Energy': 'Energy', 'f_Financials': 'Financials', 'f_Health Care': 'Health Care', 'f_Industrials': 'Industrials', 'f_Information Technology': 'Information Technology', 'f_Materials': 'Materials', 'f_Real Estate': 'Real Estate', 'f_Utilities': 'Utilities'})#
Display name of the known factor files; any other factor shows its file name without the
f_prefix.
- FILE_LIST = '{count} ({names})'#
A count of items followed by their names.
- FINDINGS = mappingproxy({'headline': 'Bottom line: the portfolio returned {portfolio:.2%} against {benchmark:.2%} for its benchmark, an active return of {active:+.2%} ({annualized:+.2%} a year).', 'headline_without_benchmark': 'Bottom line: the portfolio returned {portfolio:.2%} ({annualized:.2%} a year); no benchmark was attributed.', 'window': 'The window runs from {start:%Y-%m-%d} to {end:%Y-%m-%d}: {dates} dates with a return.', 'no_statistics': 'No date in the window has a portfolio return, so the report has no performance statistics.', 'risk': 'The active return came with a tracking error of {tracking_error:.2%} a year, an information ratio of {information_ratio:.2f}; the portfolio beat the benchmark on {hit_rate:.0%} of the days.', 'effects_linked': 'Brinson-Fachler splits the active return of {active:+.2%} into allocation {allocation:+.2%}, selection {selection:+.2%} and interaction {interaction:+.2%}.', 'effects_summed': "Summed day by day (not linked), Brinson-Fachler's active return of {active:+.2%} splits into allocation {allocation:+.2%}, selection {selection:+.2%} and interaction {interaction:+.2%}.", 'largest_effect': '{effect} is the largest of the three effects in absolute size.', 'selection_with_interaction': 'Counting interaction with selection, as many managers report it, selection comes to {value:+.2%}.', 'best_and_worst_year': 'By calendar year, the best active return was {best_value:+.2%} in {best} and the worst {worst_value:+.2%} in {worst}.', 'factor_split': "Of the factor model's cumulative portfolio return of {portfolio:.2%}, the factors account for {factors:+.2%} ({factor_share:.1%} of it) and the idiosyncratic residual for {idiosyncratic:+.2%} ({idiosyncratic_share:.1%}).", 'factor_split_without_shares': "The factor model's cumulative portfolio return is {portfolio:.2%}: the factors account for {factors:+.2%} and the idiosyncratic residual for {idiosyncratic:+.2%}.", 'component': '{component} accounts for {value:+.2%} ({share:.1%} of the return).', 'component_without_share': '{component} accounts for {value:+.2%}.', 'larger_part_factors': 'The factors are the larger part.', 'larger_part_idiosyncratic': 'The idiosyncratic residual is the larger part: what these factors do not explain, not a measure of skill.', 'best_and_worst_factor': 'The largest positive contribution came from {best} ({best_value:+.2%}) and the largest drag from {worst} ({worst_value:+.2%}).', 'best_factor_only': 'The largest contribution came from {best} ({best_value:+.2%}); no factor detracted.', 'worst_factor_only': 'No factor contributed positively; the largest drag came from {worst} ({worst_value:+.2%}).', 'active_component': '{component} accounts for {value:+.2%} of the active return.', 'active_factor_split': "Against the benchmark's holdings, the factors account for {factors:+.2%} of the active return of {active:+.2%} and the idiosyncratic residual for {idiosyncratic:+.2%}.", 'implementation': "The Backtest Engine's NAV returned {engine:.2%} against {holdings:.2%} for the holdings attributed here. Summed over the dates, commissions cost {commissions:+.2%}, slippage {slippage:+.2%}, financing {financing:+.2%} and execution {execution:+.2%}.", 'no_diagnostics': 'The run logged no warnings; the checks sheet lists its parameters and method.', 'diagnostics': 'Warnings logged by the run: {warnings}; expected: {expected}; notes: {notes}. The checks sheet lists each one and what to check.'})#
each is written only when the numbers it cites are in the report.
- Type:
Key-findings sentences
- FOOTER_PAGE = 'Page &P of &N'#
Print footer;
&Pand&Nare Excel’s page number and page count.
- INFO_LABELS = mappingproxy({'start_date': 'Start date', 'end_date': 'End date', 'return_dates': 'Return dates', 'methods': 'Methods', 'benchmark': 'Benchmark', 'generated': 'Generated (UTC)'})#
The info block under the summary’s figures.
- KPI_LABELS = mappingproxy({'portfolio_return': 'Portfolio return', 'benchmark_return': 'Benchmark return', 'active_return': 'Active return', 'tracking_error': 'Tracking error', 'information_ratio': 'Information ratio', 'max_drawdown': 'Maximum drawdown'})#
The figures across the top of the summary.
- METHODOLOGY = mappingproxy({'basis_holdings': 'Holdings-based: the start-of-day weights given, priced at the asset prices. Trades within a day are not seen.', 'basis_backtest': "Hypothetical: a Backtest Engine simulation, attributed on its start-of-day holdings at the engine's mark-to-market prices.", 'costs_gross': 'Gross: before fees and trading costs.', 'costs_backtest': "Gross: before costs. The implementation block shows commissions, slippage, financing and execution between the holdings return and the engine's NAV return.", 'periods_carino': "Daily periods, linked with Carino's logarithmic smoothing: the cumulative effects add up exactly to the compounded return difference, whatever the order of the days.", 'periods_grap': "Daily periods, linked with GRAP: the cumulative effects add up exactly to the compounded return difference; each day's effect depends on the days around it.", 'periods_none': 'Daily periods, not linked: cumulative effects are running sums that add up to the sum of the daily returns, not to the compounded return.', 'excess': 'Arithmetic: portfolio return minus benchmark return.', 'interaction': "Shown on its own; the 'Selection incl. interaction' subtotal adds it to selection.", 'residual_linked': 'None by construction: allocation, selection and interaction add up to the active return, up to rounding.', 'residual_none': 'Sums of the daily effects, which add up to the sum of the daily active returns.', 'benchmark': 'Built from the benchmark weights and the asset prices (the holdings benchmark), and checked against the reported benchmark returns when they are given: see the warnings below.', 'factor_model': "The factor files' contributions as given (exposure x factor return). The idiosyncratic residual is what these factors do not explain: another factor model can split the same return differently.", 'annualization': '252 return dates a year.'})#
How the numbers were computed, as the CFA Institute’s draft guide on attribution reporting lists it.
- MORE_ITEMS = '{shown} and {more} more'#
the first items, then how many were left out.
- Type:
A list cut short
- RELATIVE_LABELS = mappingproxy({'Active Return': 'Active return (compounded)', 'Annualized Active Return': 'Annualized active return', 'Tracking Error': 'Tracking error (annualized)', 'Information Ratio': 'Information ratio', 'Beta': 'Beta', 'Hit Rate': 'Hit rate (days ahead of the benchmark)'})#
Row label of each
relative_statskey; an unknown key is shown as it is.
- SHEET_DESCRIPTIONS = mappingproxy({'summary': 'The headline numbers, the key findings, the tables by year and the charts.', 'checks': "The run's parameters, how it was computed and every warning or note it logged.", 'how_to_read': 'What each effect and term in this report means, and what each sheet holds.', 'bf_per_period': 'One row per date: portfolio and benchmark return, the active return and its split into allocation, selection and interaction.', 'bf_cumulative': 'The same columns, cumulative to each date (linked, or running sums with linking none).', 'bf_by_year': 'One row per calendar year, linked within the year: returns, active return and its split.', 'factor_contributions': "One row per date: each factor's contribution to the portfolio return (and the carry and dividend components, when given).", 'factor_cumulative': "Each factor's contribution, cumulative to each date.", 'factor_totals': 'Cumulative portfolio return, all factors together, the components and the idiosyncratic residual.', 'factor_by_year': 'One row per calendar year, linked within the year: portfolio return, factors, components and residual.', 'factor_daily_shares': "Each factor's share of each day's portfolio return; the residual is the idiosyncratic share.", 'factor_shares': "Each factor's share of the cumulative portfolio return; the shares add up to 100%.", 'active_returns': 'One row per date: portfolio, holdings benchmark and active return.', 'active_contributions': "Each factor's contribution to the active return (portfolio minus benchmark), per date.", 'active_cumulative': 'The active contributions, cumulative to each date.', 'active_totals': 'Cumulative portfolio, benchmark and active return, split into factors and the residual.', 'implementation': "One row per date: the engine's NAV return, the holdings return and the costs between them (negative returns, as fractions of the previous NAV).", 'chart_data': "The values the summary's charts draw: the bridge from benchmark to portfolio, and the factors."})#
One line under each sheet’s title, and the contents of the summary and of the how-to-read sheet.
- SHEET_NAMES = mappingproxy({'summary': 'summary', 'checks': 'checks', 'how_to_read': 'how_to_read', 'bf_per_period': 'bf_per_period', 'bf_cumulative': 'bf_cumulative', 'bf_by_year': 'bf_by_year', 'factor_contributions': 'factor_contributions', 'factor_cumulative': 'factor_cumulative', 'factor_totals': 'factor_totals', 'factor_by_year': 'factor_by_year', 'factor_daily_shares': 'factor_daily_shares', 'factor_shares': 'factor_shares', 'active_returns': 'active_returns', 'active_contributions': 'active_contributions', 'active_cumulative': 'active_cumulative', 'active_totals': 'active_totals', 'implementation': 'implementation', 'chart_data': 'chart_data'})#
Sheet (tab) names, at most 31 characters each, in workbook order.
- SHEET_TITLES = mappingproxy({'checks': 'Checks', 'how_to_read': 'How to read this report', 'bf_per_period': 'Brinson-Fachler, per period', 'bf_cumulative': 'Brinson-Fachler, cumulative', 'bf_by_year': 'Brinson-Fachler, by calendar year', 'factor_contributions': 'Factor model, daily contributions', 'factor_cumulative': 'Factor model, cumulative contributions', 'factor_totals': 'Factor model, cumulative totals', 'factor_by_year': 'Factor model, by calendar year', 'factor_daily_shares': 'Factor model, daily shares of return', 'factor_shares': 'Factor model, shares of the cumulative return', 'active_returns': 'Active factor model, returns', 'active_contributions': 'Active factor model, daily contributions', 'active_cumulative': 'Active factor model, cumulative contributions', 'active_totals': 'Active factor model, cumulative totals', 'implementation': 'Implementation (Backtest Engine)', 'chart_data': 'Chart data'})#
Title in cell A1 of every sheet but the summary, whose title is the report name.
- STATISTIC_LABELS = mappingproxy({'Total Return': 'Total return (compounded)', 'Annualized Return': 'Annualized return', 'Annualized Vol': 'Annualized volatility', 'Sharpe Ratio': 'Sharpe ratio', 'Max Drawdown': 'Maximum drawdown', 'Skewness': 'Skewness', 'Kurtosis': 'Kurtosis (3 for a normal distribution)', 'Cornish-Fisher VaR (5%)': 'Cornish-Fisher VaR (5%), daily', 'Historic CVaR (5%)': 'Historic CVaR (5%), daily'})#
Row label of each
summary_statskey; an unknown key is shown as it is.
- STYLE_NAMES = mappingproxy({'date': 'Attribution date', 'daily_percent': 'Attribution daily percent', 'daily_signed': 'Attribution daily signed percent', 'integer': 'Attribution integer', 'percent': 'Attribution percent', 'signed_percent': 'Attribution signed percent', 'text': 'Attribution text'})#
Names of the cell styles of the data sheets, which Excel lists among the workbook’s cell styles.