Asset panel summary: private API

Types

PortfolioOptimisers.PanelFieldCoverage — Type
struct PanelFieldCoverage{__T_cells, __T_missing, __T_active, __T_active_missing, __T_assets_missing}

Holds the counts of the cells and of the missing cells of one Panel Field, over all cells and over the active cells.

This type is an implementation detail and is not intended for direct use. panel_field_coverage makes it, and DataFrames.describe(pnl::AssetPanel) and panel_info read it.

Fields

  • cells: cells: The count of cells.
  • missing: missing: The count of missing cells.
  • active: active: The count of active cells.
  • active_missing: active_missing: The count of missing active cells.
  • assets_missing: assets_missing: The count of assets whose active cells are all missing.

Related

source
PortfolioOptimisers.PanelMaskCoverage — Type
struct PanelMaskCoverage{__T_cells, __T_in_mask, __T_per_observation, __T_assets, __T_N, __T_durations}

Holds the counts of the cells of one universe mask, and the spread of its assets for each observation and of its observations for each asset.

This type is an implementation detail and is not intended for direct use. panel_mask_coverage makes it, and panel_info_mask prints it.

Fields

  • cells: cells: The count of cells.
  • in_mask: in_mask: The count of true cells.
  • per_observation: per_observation: The spread of the count of assets for each observation, or nothing when the mask has no observation.
  • assets: assets: The count of assets with one true cell or more.
  • N: N: The count of assets.
  • durations: durations: The spread of the count of observations for each asset with one true cell or more, or nothing when no asset has one.

Related

source

Functions

PortfolioOptimisers.panel_field_kind — Function
panel_field_kind(f::NumericPanelField) -> Symbol
panel_field_kind(f::CategoricalPanelField) -> Symbol
panel_field_kind(f::TensorPanelField) -> Symbol

Return the kind of a Panel Field as a symbol, for a summary table.

Algorithm

The method that Julia selects is the algorithm. It returns :numeric, :categorical or :tensor.

Arguments

  • f: The Panel Field.

Returns

  • kind::Symbol: The kind of the Panel Field.

Related

source
PortfolioOptimisers.panel_field_width — Function
panel_field_width(f::AbstractPanelField) -> Int
panel_field_width(f::TensorPanelField) -> Int

Return the count of cells that one pair of observation and asset holds in a Panel Field.

A numeric and a categorical Panel Field hold one cell for each pair. A tensor Panel Field holds one cell for each label of its label axis.

Algorithm

The method that Julia selects is the algorithm.

Arguments

  • f: The Panel Field.

Returns

  • K::Int: The count of cells for each pair of observation and asset.

Related

source
PortfolioOptimisers.panel_field_missing — Function
panel_field_missing(f::AbstractPanelField) -> AbstractArray{<:Integer}

Count the cells of a Panel Field that the raw source did not observe, for each pair of observation and asset.

A cell is missing when the observed mask of the Panel Field is false there. A fill policy wrote the value of a missing cell, or the cell holds a placeholder. A Panel Field with no observed mask cannot blank, so it has no missing cell. A tensor Panel Field holds one cell for each label, so its count for one pair is from 0 to the count of labels.

Algorithm

  1. Read the axes of the Panel Field with panel_field_axes.
  2. If the observed mask is nothing, return zeros over the axes.
  3. Otherwise count the false cells of each pair: one cell on a field with no label axis, and the cells of every label, on the second axis, on a tensor field. The count is over the observation and asset axes, so the count of a time-varying tensor field takes the observations first.

Arguments

  • f: The Panel Field.

Returns

  • miss::AbstractArray{<:Integer}: The count of missing cells, over the observation and asset axes of the Panel Field.

Related

source
PortfolioOptimisers.panel_active_cells — Function
panel_active_cells(pnl::AssetPanel) -> AbstractArray{Bool}
panel_active_cells(pnl::Nothing) -> Nothing

Return the active cells of an AssetPanel over its observation and asset axes, or nothing.

A static panel has no active mask. Each asset of a static panel is in its universe, so every cell is active.

A returns result without a panel states no mask, so no cell of it is known to be active. The method on Nothing answers nothing, the answer "no mask", and a reader such as attribution_net_returns then treats no blank cell as a holiday.

Algorithm

  1. If the panel is static, return a true array over panel_axes.
  2. Otherwise return the active mask.

Arguments

  • pnl: The Asset Panel, or nothing.

Returns

  • act::Option{<:AbstractArray{Bool}}: The active cells, or nothing.

Related

source
PortfolioOptimisers.panel_field_coverage — Function
panel_field_coverage(f::AbstractPanelField, act::AbstractArray{Bool}) -> PanelFieldCoverage

Count the cells and the missing cells of a Panel Field, over all cells and over the active cells.

Algorithm

  1. Count the missing cells of each pair of observation and asset with panel_field_missing.
  2. Count the cells, the active cells, the missing cells and the missing active cells. A pair holds panel_field_width cells.
  3. Count the assets that are active at one observation or more, and whose active cells are all missing.

Arguments

Returns

  • cov::PanelFieldCoverage: The five counts.

Related

source
PortfolioOptimisers.panel_level_coverage — Function
panel_level_coverage(f::AbstractPanelField, g::CategoricalPanelField, k::Integer,
                     act::AbstractArray{Bool}) -> Tuple{Int, Int}

Count the cells and the missing cells of a Panel Field on the cells of one level of a categorical Panel Field.

A cell belongs to the level when it is active, and when g is observed there and holds the code k. A filled category is not an observation of its level.

Algorithm

  1. Mark the cells of the level: active, observed in g, and code k.
  2. Count the missing cells of f with panel_field_missing on the marked cells, and the marked cells times panel_field_width.

Arguments

  • f: The Panel Field to count.
  • g: The categorical Panel Field that groups the cells.
  • k: The code of the level.
  • act: The active cells, see panel_active_cells.

Returns

  • (cells, missing)::Tuple{Int, Int}: The count of cells of the level, and the count of missing cells among them. The caller takes the pair apart at once.

Related

source
PortfolioOptimisers.panel_level_cells — Function
panel_level_cells(g::CategoricalPanelField, k::Integer, act::AbstractArray{Bool}) -> BitArray

Mark the cells that hold one level of a categorical Panel Field.

A cell holds the level when it is active, and when g is observed there and holds the code k. A categorical Panel Field with no observed mask is observed at each cell.

Algorithm

  1. Compare each code of g with k, and intersect with act.
  2. Intersect with the observed mask of g when it has one.

Arguments

  • g: The categorical Panel Field.
  • k: The code of the level.
  • act: The active cells, see panel_active_cells.

Returns

  • member::BitArray: The cells of the level.

Related

source
PortfolioOptimisers.panel_mask_coverage — Function
panel_mask_coverage(msk::AbstractMatrix{Bool}) -> PanelMaskCoverage

Count the cells of a universe mask, and the spread of its assets for each observation and of its observations for each asset.

Algorithm

  1. Count the cells and the true cells of msk.
  2. Count the true cells of each observation, and take their spread with panel_spread.
  3. Count the true cells of each asset, keep the assets with one true cell or more, and take their spread.

Arguments

  • msk: The universe mask, observations × assets.

Returns

  • cov::PanelMaskCoverage: The counts and the two spreads.

Related

source
PortfolioOptimisers.panel_percent — Function
panel_percent(x::Real) -> Real

Return a share as a percentage, rounded to one decimal, for a report.

Algorithm

  1. Multiply x by 100, and round the product to one decimal.

Arguments

  • x: The share.

Returns

  • p::Real: The percentage.

Related

source
PortfolioOptimisers.panel_info_fields — Function
panel_info_fields(io::IO, pnl::AssetPanel, cs::AbstractVector) -> nothing

Print one line for each Panel Field of an Asset Panel: its kind, its cells, its missing share of all cells and of the active cells, and the count of assets whose active cells are all missing.

The numbers are the ones of DataFrames.describe(pnl::AssetPanel), with the shares as percentages.

Algorithm

  1. Pad the name column to the widest Panel Field name, as textwidth measures it. A name in a wide script, such as Chinese, takes two columns for each character.
  2. Print the header, then one line for each Panel Field from its counts.

Arguments

Returns

  • nothing.

Related

source
PortfolioOptimisers.panel_info_header — Function
panel_info_header(io::IO, pnl::AssetPanel, ts::Option{<:AbstractVector},
                  cs::AbstractVector) -> nothing

Print the dimensions of an Asset Panel and the missing share of its cells. These lines start the report of panel_info.

Algorithm

  1. Check the length of ts against the observation axis of a time-varying panel.
  2. Print the count of observations, with the first and the last of ts when it is given, the count of assets, the count of Panel Fields and the count of cells.
  3. Add the counts of the Panel Fields, and print the missing share of all cells and of the active cells.

Arguments

  • io: The stream.
  • pnl: The Asset Panel.
  • ts: The timestamps of the observations, or nothing. A static panel does not read it.
  • cs: The counts of each Panel Field, see panel_field_coverage.

Validation

  • length(ts) is the count of observations of a time-varying panel. Raises a DimensionMismatch.

Returns

  • nothing.

Related

source
PortfolioOptimisers.panel_info_mask — Function
panel_info_mask(io::IO, title::AbstractString, msk::Nothing) -> nothing
panel_info_mask(io::IO, title::AbstractString, msk::AbstractMatrix{Bool}) -> nothing

Print the coverage of one universe mask of an Asset Panel.

Algorithm

The method that Julia selects is the algorithm.

  1. If msk is nothing, the panel is static. Print that it has no mask.
  2. Otherwise read panel_mask_coverage, and print the true cells, the spread of the assets for each observation, the count of assets in the mask and the spread of their durations.

Arguments

  • io: The stream.
  • title: The name of the mask.
  • msk: The universe mask, or nothing.

Returns

  • nothing.

Related

source
PortfolioOptimisers.panel_info_levels — Function
panel_info_levels(io::IO, pnl::AssetPanel, g::CategoricalPanelField,
                  act::AbstractArray{Bool}) -> nothing

Print the levels of one categorical Panel Field, grouped by the smallest count of assets that holds each level over the observations.

A level with few assets gives a noisy cross-sectional estimate, so the report puts each level in one of four groups: fewer than 10 assets, 10 to 19, 20 to 49, and 50 or more. The count of one level at one observation is the count of cells of the level, see panel_level_cells. An observation where the level holds no asset counts zero, so a level that holds no asset at one observation or more is in the first group. A static panel has one count for each level.

Algorithm

  1. For each level, mark its cells with panel_level_cells, count them at each observation, and take the minimum.
  2. For each group, print the count of its levels and their names. A group of more than six levels prints the first four names and the count of the others. A group of one level prints 1 level.

Arguments

  • io: The stream.
  • pnl: The Asset Panel.
  • g: The categorical Panel Field.
  • act: The active cells, see panel_active_cells.

Returns

  • nothing.

Related

source
PortfolioOptimisers.panel_observed_cells — Function
panel_observed_cells(f::AbstractPanelField) -> Option{AbstractArray{Bool}}

Return where a Panel Field holds an observed value, over its observation and asset axes.

A tensor Panel Field holds an observed value for a pair of observation and asset when each of its labels is observed there. A Panel Field with no observed mask cannot blank, so it is observed at each cell, and the function returns nothing for it.

Algorithm

  1. If the observed mask is nothing, return nothing.
  2. Otherwise return the pairs that panel_field_missing counts no missing cell for.

Arguments

  • f: The Panel Field.

Returns

  • obs::Option{AbstractArray{Bool}}: The observed pairs, or nothing when each pair is observed.

Related

source