Asset panel summary: private API

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 trailing 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 builder filled, for each pair of observation and asset.

A cell is missing when the observed mask of the Panel Field is false there. 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. The observed mask is nothing: return zeros over the axes.
  3. Otherwise put the cells of each pair in one row, and count the false cells of each row.

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}

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

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

Algorithm

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

Arguments

  • pnl: The Asset Panel.

Returns

  • act::AbstractArray{Bool}: The active cells.

Related

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

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::NamedTuple: cells, the count of cells; missing, the count of missing cells; active, the count of active cells; active_missing, the count of missing active cells; assets_missing, the count of assets whose active cells are all missing.

Related

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

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

  • cov::NamedTuple: cells, the count of cells of the level; missing, the count of missing cells among them.

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_spread — Function
panel_spread(v::AbstractVector{<:Real}) -> Option{NamedTuple}

Return the minimum, the median and the maximum of a vector of counts, or nothing when it is empty.

Algorithm

  1. v is empty: return nothing.
  2. Otherwise return the minimum, the median and the maximum of v.

Arguments

  • v: The counts.

Returns

  • s::Option{NamedTuple}: min, median and max, or nothing.

Related

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

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::NamedTuple: cells, the count of cells; in_mask, the count of true cells; per_observation, the spread of the count of assets for each observation; assets, the count of assets with one true cell or more; N, the count of assets; durations, the spread of the count of observations for each of those assets.

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 longest Panel Field name.
  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, the first lines 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. msk is nothing: the panel is static, so 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. 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.

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. 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