Custom value expected returns: private API

PortfolioOptimisers.CER_Func_Num_VecNumType
const CER_Func_Num_VecNum = Union{<:CustomExpectedReturnsValueAlgorithm,<:Func_Num_VecNum}

Alias for supported types for the val field in CustomValueExpectedReturns.

The group exists because the three shapes are a single field's contract, not three fields. The bound is written once here, so the field, the keyword constructor and the three mean methods cannot drift apart on what val may be.

Related

source
PortfolioOptimisers.assert_custom_expected_returns_valFunction
assert_custom_expected_returns_val(val, N::Integer)
assert_custom_expected_returns_val(
    val,
    N::Integer,
    val_sym::Union{AbstractString, Symbol}
)

Assert that a custom expected returns value is a per-asset vector of the expected length.

Both the vector field of CustomValueExpectedReturns and the value returned by a callable val must be a vector of numbers with one element per asset. The callable is checked at the point of call, which is the only seam that can see what the callable returned.

Arguments

  • val: Custom value to validate. Either the stored me.val vector or the value returned by a callable me.val.
  • N: Number of assets implied by the data matrix and dims.
  • val_sym: Symbolic name used in the error messages.

Validation

  • isa(val, VecNum), or an ArgumentError is thrown. A scalar, a function and a matrix all fail here, and the message names val_sym and the type it was given.
  • length(val) == N, or a DimensionMismatch is thrown. The message names val_sym, the length it was given, and N.

Returns

  • nothing.

Related

source