Portfolio report: private API
PortfolioOptimisers.assert_report_length — Function
assert_report_length(x::Option{<:UniverseSets}, n::Integer, name::Symbol)
assert_report_length(x::AbstractVector, n::Integer, name::Symbol)Check that a keyword of portfolio_report gives one value for each prediction.
One UniverseSets is the sets of every prediction, so it has no length to check.
Arguments
x: The values of the keyword, oneUniverseSets, ornothing.n: The number of predictions.name: The name of the keyword.
Validation
length(x) == n. Otherwise the function raises aDimensionMismatchthat names the keyword.
Returns
nothing.
Related
PortfolioOptimisers.report_item — Function
report_item(x::Option{<:UniverseSets}, k::Integer)
report_item(x::AbstractVector, k::Integer)The value of a keyword of portfolio_report for prediction k: entry k of the keyword, the one UniverseSets of every prediction, or nothing when the keyword gives none.
Related
PortfolioOptimisers.report_figure_pairs — Function
report_figure_pairs(figs, name::Symbol) -> VectorCheck the figures of portfolio_report, and collect them into a vector of pairs caption => f.
Arguments
figs: A collection of pairscaption => f.name: The name of the keyword.
Validation
- Each element is a pair whose first part is an
AbstractString. Otherwise the function raises anArgumentErrorthat names the keyword.
Returns
figs::Vector: The pairs, in order.
Related
PortfolioOptimisers.report_figures — Function
report_figures(figs::AbstractVector, args...) -> Vector{AbstractReportBlock}The figures of a report: one ReportFigure for each pair caption => f of figs whose f(args...) is not nothing.
A function that throws stops the build with its own error.
Arguments
figs: The pairs, fromreport_figure_pairs.args...: The prediction of an entry, or the vector of predictions of the overview and their names.
Returns
blocks::Vector{AbstractReportBlock}: The figures, in the order offigs.
Related
PortfolioOptimisers.overview_table — Function
overview_table(df::DataFrames.AbstractDataFrame, nm::AbstractVector,
groups::Option{<:AbstractVector}) -> DataFrames.DataFrameThe table of the overview of a Portfolio Report: the summary table, with a group column first when the caller gives groups.
Arguments
df: The summary table.nm: The name of each prediction.groups: The group of each prediction, ornothing.
Returns
tab::DataFrames.DataFrame: The table.
Related
PortfolioOptimisers.entry_sections — Function
entry_sections(pred::AbstractPredictionResult, rows::DataFrames.AbstractDataFrame,
alloc, threshold::Real, figs::AbstractVector,
sets::Option{<:UniverseSets},
taxonomy::AbstractVector{<:AbstractString}) -> Vector{ReportSection}The sections of the entry of one prediction, in the order that portfolio_report states.
The Allocation section is built before the Exposure section, so the checks of the allocation run before the Exposure section reads it.
Arguments
pred: The prediction.rows: The rows of the summary table of the prediction.alloc: The finite allocation result of the prediction, ornothing.threshold: The least absolute weight that a weights table shows.figs: The figures of an entry, fromreport_figure_pairs.sets: TheUniverseSetsof the prediction, ornothing.taxonomy: The names of the taxonomy columns ofsets.
Returns
sections::Vector{ReportSection}: Statistics, Weights, then Exposure, Allocation and Figures when the entry has them.
Related
PortfolioOptimisers.statistics_table — Function
statistics_table(rows::DataFrames.AbstractDataFrame) -> ReportTableThe table of the statistics of one prediction.
The name column is not shown, and the path and member columns are shown only when they hold a key. One row gives a table of two columns, the figure and its value. Many rows give a sortable table, one row for each path and member.
Arguments
rows: The rows of the summary table of the prediction.
Returns
tab::ReportTable: The table.
Related
PortfolioOptimisers.distribution_table — Function
distribution_table(rows::DataFrames.AbstractDataFrame) -> ReportTableThe distribution of each figure of a population over its paths.
A figure is a column of the summary table other than the keys and the dates. For each figure, the table gives the count of finite values, and the minimum, the 25 % quantile, the median, the 75 % quantile and the maximum of those values. A figure with no finite value shows empty cells.
Arguments
rows: The rows of the summary table of the population.
Returns
tab::ReportTable: The table, one row for each figure.
Related
PortfolioOptimisers.report_statistics — Function
report_statistics(pred::PredRes_MultiPredRes, rows::DataFrames.AbstractDataFrame)
report_statistics(pred::PopulationPredictionResult, rows::DataFrames.AbstractDataFrame)The Statistics section of the entry of one prediction: its table of statistics, and for a population the distribution of each figure over its paths.
Arguments
pred: The prediction.rows: The rows of the summary table of the prediction.
Returns
s::ReportSection: The section.
Related
PortfolioOptimisers.report_weights — Function
report_weights(pred::AbstractPredictionResult, threshold::Real) -> ReportSectionThe Weights section of the entry of one prediction, one table for each member.
Arguments
pred: The prediction.threshold: The least absolute weight that a row shows.
Returns
s::ReportSection: The section.
Related
PortfolioOptimisers.weights_table — Function
weights_table(names::AbstractVector, W::MatNum, labels::AbstractVector,
threshold::Real, prefix::AbstractString) -> ReportTableThe weights table of one member of a prediction, from the rows of prediction_weights.
One row of W gives one column of weights. Many rows give a mean column, the mean over the rows, then one column for each row. The rows of the table are sorted by the absolute value of the first column of weights. A row whose largest absolute weight is less than threshold is not shown. A NaN weight is not less than threshold, so its row shows.
Arguments
names: The asset names.W: The weights, one row for each portfolio of the prediction.labels: The label of each row ofW.threshold: The least absolute weight that a row shows.prefix: The start of the caption, which names the member.
Returns
tab::ReportTable: The table.
Related
PortfolioOptimisers.report_exposure — Function
report_exposure(pred::AbstractPredictionResult, sets::Nothing,
taxonomy::AbstractVector, alloc)
report_exposure(pred::AbstractPredictionResult, sets::UniverseSets,
taxonomy::AbstractVector{<:AbstractString}, alloc)The Exposure section of the entry of one prediction, or nothing when the entry has no sets or taxonomy is empty.
The section holds one subsection for each name of taxonomy, from exposure_section, and each subsection holds one table for each member. portfolio_report states the content of the tables.
Arguments
pred: The prediction.sets: TheUniverseSetsof the prediction, ornothing.taxonomy: The names of the taxonomy columns ofsets.alloc: The finite allocation result of the prediction, ornothing. Its checks ran inreport_allocation.
Returns
s::Option{<:ReportSection}: The section, ornothing.
Related
PortfolioOptimisers.exposure_section — Function
exposure_section(sets::UniverseSets, key::AbstractString, ws::AbstractVector,
aw::Option{<:Tuple}) -> ReportSectionThe subsection of the Exposure section for one taxonomy column: one table for each member, from exposure_table. The allocation is the allocation of the first member, so only its table reads aw.
Arguments
sets: TheUniverseSets.key: The name of the taxonomy column, and the title of the subsection.ws: The rows ofprediction_weightsof each member.aw: The realised weights of the allocation, fromallocation_weights, ornothing.
Returns
s::ReportSection: The subsection.
Related
PortfolioOptimisers.allocation_weights — Function
allocation_weights(pred::AbstractPredictionResult, alloc::Nothing)
allocation_weights(pred::PredictionResult, alloc::FiniteAllocationOptimisationResult)
allocation_weights(pred::MultiPeriodPredictionResult, alloc::FiniteAllocationOptimisationResult)The realised weights of a finite allocation on the names of the portfolio that it allocates, or nothing when the entry has no allocation.
A single fold reads the names of its weights, and a path reads the names of its last fold, as report_allocation does.
Arguments
pred: The prediction.alloc: The finite allocation result, ornothing.
Returns
aw::Option{<:Tuple}: The pair(names, w), ornothing.
Related
PortfolioOptimisers.exposure_labels — Function
exposure_labels(sets::UniverseSets, key::AbstractString,
names::AbstractVector) -> Vector{String}The group label of each asset of names, from the taxonomy column sets.dict[key].
An asset maps to its label by name, through sets.dict[sets.xkey]. An asset that the universe does not name, or whose label is missing, takes the label (none).
Arguments
sets: TheUniverseSets.key: The name of the taxonomy column.names: The asset names.
Validation
haskey(sets.dict, key), throughtaxonomy_column.length(sets.dict[key]) == length(sets.dict[sets.xkey]). Otherwise the function raises aDimensionMismatch.
Returns
labels::Vector{String}: One label for each name.
Related
PortfolioOptimisers.exposure_sums — Function
exposure_sums(labels::AbstractVector{<:AbstractString}, w::AbstractVector,
groups::AbstractVector{<:AbstractString}) -> TupleThe long and the short sums of the weights w in each group of groups.
The long sum adds max(x, 0) and the short sum adds min(x, 0) for each weight x of the group, so a short shows on the short side, and a NaN weight gives a NaN on both sides. The sums take the element type of w.
Arguments
labels: The group label of each weight.w: The weights.groups: The groups, which hold every label oflabels.
Returns
L::Vector: The long sum of each group.S::Vector: The short sum of each group, which is not positive.
Related
PortfolioOptimisers.exposure_table — Function
exposure_table(sets::UniverseSets, key::AbstractString, names::AbstractVector,
W::MatNum, labels::AbstractVector, aw::Option{<:Tuple},
prefix::AbstractString) -> ReportTableThe Exposure table of one member of a prediction for one taxonomy column, from the rows of prediction_weights.
The groups are the labels of the assets of names and of the allocation, in order of first appearance, with (none) last. One row of W gives the table of exposure_group_table, and many rows give the table of exposure_row_table.
Arguments
sets: TheUniverseSets.key: The name of the taxonomy column.names: The asset names of the columns ofW.W: The weights, one row for each portfolio of the prediction.labels: The label of each row ofW.aw: The realised weights of the allocation, fromallocation_weights, ornothing.prefix: The start of the caption, which names the member.
Returns
tab::ReportTable: The table.
Related
PortfolioOptimisers.exposure_group_table — Function
exposure_group_table(groups::AbstractVector, s::Tuple, asum::Option{<:Tuple},
lead::AbstractString) -> ReportTableThe Exposure table of one row of weights: one row for each group, with the columns long, short and net, and the same three columns of the allocation after the prefix alloc_.
The rows are sorted by the absolute value of net, and the caption gives the gross exposure.
Arguments
groups: The groups.s: The long and the short sums of the weights, fromexposure_sums.asum: The long and the short sums of the realised weights of the allocation, ornothing.lead: The start of the caption.
Returns
tab::ReportTable: The table.
Related
PortfolioOptimisers.exposure_row_table — Function
exposure_row_table(groups::AbstractVector, sums::AbstractVector,
labels::AbstractVector, asum::Option{<:Tuple},
lead::AbstractString) -> ReportTableThe Exposure table of many rows of weights: one row for each portfolio of the prediction, with the column portfolio, one column of net exposure for each group, and the column gross.
With an allocation, the last row allocation sums its realised weights. A group whose label is portfolio or gross takes the column name of its label with the first suffix _k, from _1 up, that no other column name holds. So the two fixed columns keep their names, and a group gross_1 beside a group gross makes the renamed column gross_2.
Arguments
groups: The groups.sums: The long and the short sums of each row of weights, fromexposure_sums.labels: The label of each row of weights.asum: The long and the short sums of the realised weights of the allocation, ornothing.lead: The start of the caption.
Returns
tab::ReportTable: The table.
Related
PortfolioOptimisers.report_allocation — Function
report_allocation(pred::AbstractPredictionResult, alloc::Nothing)
report_allocation(pred::PredictionResult, alloc::FiniteAllocationOptimisationResult)
report_allocation(pred::MultiPeriodPredictionResult, alloc::FiniteAllocationOptimisationResult)
report_allocation(pred::PopulationPredictionResult, alloc::FiniteAllocationOptimisationResult)The Allocation section of the entry of one prediction, or nothing when the entry has no allocation.
A finite allocation is the allocation of one portfolio. A single fold reads the names of its weights. A path reads the names of its last fold, the portfolio to hold now. A population holds no single portfolio, so it has no allocation.
Arguments
pred: The prediction.alloc: The finite allocation result, ornothing.
Validation
length(alloc.shares)is the number of assets of the portfolio. Otherwise the function raises aDimensionMismatch.- A population has no allocation. Otherwise the function raises an
ArgumentError.
Returns
s::Option{<:ReportSection}: The section, ornothing.
Related