Errors

Most types of PortfolioOptimisers.jl check their values in the constructor. A method that receives such an object uses it without checking it again, which keeps the method short and fast. A check that needs data the constructor does not have runs at the start of the first function that has that data.

When a check fails, the library throws one of the error types below. The type names the kind of failure, such as a value that is nothing, an empty array or a non-finite number.

PortfolioOptimisers.IsNothingError — Type
struct IsNothingError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when an argument or value is unexpectedly nothing.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

IsNothingError(msg) -> IsNothingError

Arguments correspond to the fields above.

Examples

julia> throw(IsNothingError("Input data must not be nothing"))ERROR: IsNothingError: Input data must not be nothingStacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.IsEmptyError — Type
struct IsEmptyError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when an argument or value is unexpectedly empty.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

IsEmptyError(msg) -> IsEmptyError

Arguments correspond to the fields above.

Examples

julia> throw(IsEmptyError("Input array must not be empty"))ERROR: IsEmptyError: Input array must not be emptyStacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.IsNonFiniteError — Type
struct IsNonFiniteError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when an argument or value is unexpectedly non-finite, for example when it holds NaN or Inf.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

IsNonFiniteError(msg) -> IsNonFiniteError

Arguments correspond to the fields above.

Examples

julia> throw(IsNonFiniteError("Input array contains non-finite values"))ERROR: IsNonFiniteError: Input array contains non-finite valuesStacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.IsZeroError — Type
struct IsZeroError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when an argument or value is unexpectedly zero, such as a constraint row whose coefficients are all zero.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

IsZeroError(msg) -> IsZeroError

Arguments correspond to the fields above.

Examples

julia> throw(IsZeroError("Constraint row must not be all zero"))ERROR: IsZeroError: Constraint row must not be all zeroStacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.PropertyPathError — Type
struct PropertyPathError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when @forward_properties cannot follow a nested path, because a node in the path is nothing.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

PropertyPathError(msg) -> PropertyPathError

Arguments correspond to the fields above.

Examples

julia> throw(PropertyPathError("cannot descend path `sol.w` on `JuMPOptimisationResult`: intermediate `sol` is `nothing`"))ERROR: PropertyPathError: cannot descend path `sol.w` on `JuMPOptimisationResult`: intermediate `sol` is `nothing`Stacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.ConflictingArgumentError — Type
struct ConflictingArgumentError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when the caller gives two arguments that exclude each other. One argument must be nothing when the other is set, and the caller set both.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

ConflictingArgumentError(msg) -> ConflictingArgumentError

Arguments correspond to the fields above.

Examples

julia> throw(ConflictingArgumentError("sbgt must be nothing when bgt is a BudgetCostEstimator"))ERROR: ConflictingArgumentError: sbgt must be nothing when bgt is a BudgetCostEstimatorStacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.ObservationWeightsError — Type
struct ObservationWeightsError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when a DynamicAbstractWeights cannot resolve the observation weights for its data, because get_observation_weights has no method for the shape of that data.

A nothing from get_observation_weights means that the caller asked for no weights. It never means that the weights are not available. Each isnothing branch after it reads nothing in that way and computes an unweighted result. A DynamicAbstractWeights that resolves to nothing thus gives an unweighted answer that looks correct, with no message. The library raises this error instead.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

ObservationWeightsError(msg) -> ObservationWeightsError

Arguments correspond to the fields above.

Examples

julia> throw(ObservationWeightsError("MyWeights has no `get_observation_weights` method for a 2-dimensional input of size (3, 10)"))ERROR: ObservationWeightsError: MyWeights has no `get_observation_weights` method for a 2-dimensional input of size (3, 10)Stacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.NonPositiveWealthError — Type
struct NonPositiveWealthError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when a drifted portfolio's wealth reaches zero or turns negative over the observations it is scored on.

A drifted series divides by the wealth of the previous observation, so a wealth of zero or below is outside the domain of the series rather than a large loss inside it. The check runs before any return is formed, so a ruined window gives no partial series. A negative wealth is finite, and every leg of the record flips its sign, so nothing downstream reads the failure from a NaN. That is why the drift raises rather than returning a value.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

NonPositiveWealthError(msg) -> NonPositiveWealthError

Arguments correspond to the fields above.

Examples

julia> throw(NonPositiveWealthError("the drifted wealth must satisfy `all(>(0), wealth)`, but the wealth is -0.3975 at row 2 of the window"))ERROR: NonPositiveWealthError: the drifted wealth must satisfy `all(>(0), wealth)`, but the wealth is -0.3975 at row 2 of the windowStacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.PosdefRepairError — Type
struct PosdefRepairError{__T_msg} <: PortfolioOptimisersError

Exception type thrown when a positive definite repair returns a matrix that is not positive semidefinite.

A consumer factorises the matrix that a repair returns, or optimises over it. A matrix with an eigenvalue below the round-off of a positive semidefinite matrix gives a negative variance in one direction. Each consumer then reads a wrong number, or gets a LAPACK error that does not name the cause. The repair thus raises this error, and does not return the matrix. A singular result that is positive semidefinite to round-off is a valid covariance, and the repair returns it with no message.

Fields

  • msg: Error message that states the condition that caused the exception.

Constructors

PosdefRepairError(msg) -> PosdefRepairError

Arguments correspond to the fields above.

Examples

julia> throw(PosdefRepairError("the repair of `Newton()` must give a matrix whose smallest eigenvalue is at least -8.881784197001252e-16, but it is -1.0"))ERROR: PosdefRepairError: the repair of `Newton()` must give a matrix whose smallest eigenvalue is at least -8.881784197001252e-16, but it is -1.0Stacktrace: [1] top-level scope   @ none:1

Related

source
PortfolioOptimisers.DistanceReaderRefusalError — Type
struct DistanceReaderRefusalError{__T_msg, __T_idx} <: PortfolioOptimisersError

Exception type thrown when a distance reader cannot estimate the correlation of one or more assets.

A distance reader is the moment estimator and the distance estimator from which a clustering, a network or a phylogeny reads its distance matrix. It gives a NaN row and column, its diagonal entry included, for an asset whose correlation it cannot estimate. Two causes give such a row. An asset with zero variance has a correlation of 0 / 0 with every asset, itself included, see cov2cor_nan!. An asset that the CoveragePolicy of a mask-aware reader refuses while the prior keeps it gives one too, because the policy of the reader asks for more observations than the policy of the prior. A graph verb raises this error before it builds the tree or the graph. The field idx names the columns, so a fit can drop those assets from the Investable Mask and fit again, see distance_reader_refusal_mask. A fit of a hierarchical optimiser or of NestedClustered does, and so do the ple and cte readers of a JuMPOptimiser, and the readers of a ProgrammeAllocationSet in its projection programme and in the leader re-solve of a FollowTheLeader rule. Every other caller has no fit to drop the assets from, so the error reaches it: a direct call of a graph verb, the factor phylogeny of FactorRiskContribution, a selection rule, and a step of a pipeline. A reader whose estimator defines the dependence of a constant, such as GerberCovariance, gives an asset with zero variance a finite row, so it does not refuse it.

Fields

  • msg: Error message that states the condition that caused the exception.
  • idx: The columns of the matrix that the distance reader read whose correlation is NaN on the diagonal, one for each asset that the reader refuses.

Constructors

DistanceReaderRefusalError(msg, idx) -> DistanceReaderRefusalError

Arguments correspond to the fields above.

Examples

julia> throw(DistanceReaderRefusalError("the distance reader cannot estimate the correlation of 1 asset(s), at the columns [3]",                                        [3]))ERROR: DistanceReaderRefusalError: the distance reader cannot estimate the correlation of 1 asset(s), at the columns [3]Stacktrace: [1] top-level scope   @ none:1

Related

source
Base.showerror — Method
showerror(io::IO, err::PortfolioOptimisersError) -> Any

Print a subtype of PortfolioOptimisersError to io as its type name and its message, with no type parameters.

Algorithm

  1. Take name, the string of the concrete type of err.
  2. Cut name at the first { or (, so that a parametric subtype prints with its wrapper name alone.
  3. Print name, a colon, and the msg field of err.

Arguments

  • io: The stream that the function prints the message to.
  • err: The error to render.

Returns

  • nothing.

Related

source