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) -> SymbolReturn 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
PortfolioOptimisers.panel_field_width — Function
panel_field_width(f::AbstractPanelField) -> Int
panel_field_width(f::TensorPanelField) -> IntReturn 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
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
- Read the axes of the Panel Field with
panel_field_axes. - The observed mask is
nothing: return zeros over the axes. - 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
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
- The panel is static: return a true array over
panel_axes. - Otherwise return the active mask.
Arguments
pnl: The Asset Panel.
Returns
act::AbstractArray{Bool}: The active cells.
Related
PortfolioOptimisers.panel_field_coverage — Function
panel_field_coverage(f::AbstractPanelField, act::AbstractArray{Bool}) -> NamedTupleCount the cells and the missing cells of a Panel Field, over all cells and over the active cells.
Algorithm
- Count the missing cells of each pair of observation and asset with
panel_field_missing. - Count the cells, the active cells, the missing cells and the missing active cells. A pair holds
panel_field_widthcells. - Count the assets that are active at one observation or more, and whose active cells are all missing.
Arguments
f: The Panel Field.act: The active cells, seepanel_active_cells.
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
PortfolioOptimisers.panel_level_coverage — Function
panel_level_coverage(f::AbstractPanelField, g::CategoricalPanelField, k::Integer,
act::AbstractArray{Bool}) -> NamedTupleCount 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
- Mark the cells of the level: active, observed in
g, and codek. - Count the missing cells of
fwithpanel_field_missingon the marked cells, and the marked cells timespanel_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, seepanel_active_cells.
Returns
cov::NamedTuple:cells, the count of cells of the level;missing, the count of missing cells among them.
Related
PortfolioOptimisers.panel_level_cells — Function
panel_level_cells(g::CategoricalPanelField, k::Integer, act::AbstractArray{Bool}) -> BitArrayMark 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
- Compare each code of
gwithk, and intersect withact. - Intersect with the observed mask of
gwhen it has one.
Arguments
g: The categorical Panel Field.k: The code of the level.act: The active cells, seepanel_active_cells.
Returns
member::BitArray: The cells of the level.
Related
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
vis empty: returnnothing.- Otherwise return the minimum, the median and the maximum of
v.
Arguments
v: The counts.
Returns
s::Option{NamedTuple}:min,medianandmax, ornothing.
Related
PortfolioOptimisers.panel_mask_coverage — Function
panel_mask_coverage(msk::AbstractMatrix{Bool}) -> NamedTupleCount the cells of a universe mask, and the spread of its assets for each observation and of its observations for each asset.
Algorithm
- Count the cells and the true cells of
msk. - Count the true cells of each observation, and take their spread with
panel_spread. - 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
PortfolioOptimisers.panel_percent — Function
panel_percent(x::Real) -> RealReturn a share as a percentage, rounded to one decimal, for a report.
Arguments
x: The share.
Returns
p::Real: The percentage.
Related
PortfolioOptimisers.panel_info_fields — Function
panel_info_fields(io::IO, pnl::AssetPanel, cs::AbstractVector) -> nothingPrint 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
- Pad the name column to the longest Panel Field name.
- Print the header, then one line for each Panel Field from its counts.
Arguments
io: The stream.pnl: The Asset Panel.cs: The counts of each Panel Field, seepanel_field_coverage.
Returns
nothing.
Related
PortfolioOptimisers.panel_info_header — Function
panel_info_header(io::IO, pnl::AssetPanel, ts::Option{<:AbstractVector},
cs::AbstractVector) -> nothingPrint the dimensions of an Asset Panel and the missing share of its cells, the first lines of panel_info.
Algorithm
- Check the length of
tsagainst the observation axis of a time-varying panel. - Print the count of observations, with the first and the last of
tswhen it is given, the count of assets, the count of Panel Fields and the count of cells. - 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, ornothing. A static panel does not read it.cs: The counts of each Panel Field, seepanel_field_coverage.
Validation
length(ts)is the count of observations of a time-varying panel. Raises aDimensionMismatch.
Returns
nothing.
Related
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}) -> nothingPrint the coverage of one universe mask of an Asset Panel.
Algorithm
The method that Julia selects is the algorithm.
mskisnothing: the panel is static, so print that it has no mask.- 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, ornothing.
Returns
nothing.
Related
PortfolioOptimisers.panel_info_levels — Function
panel_info_levels(io::IO, pnl::AssetPanel, g::CategoricalPanelField,
act::AbstractArray{Bool}) -> nothingPrint 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
- For each level, mark its cells with
panel_level_cells, count them at each observation, and take the minimum. - 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, seepanel_active_cells.
Returns
nothing.
Related
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
- The observed mask is
nothing: returnnothing. - Otherwise return the pairs that
panel_field_missingcounts no missing cell for.
Arguments
f: The Panel Field.
Returns
obs::Option{AbstractArray{Bool}}: The observed pairs, ornothingwhen each pair is observed.
Related