Exp weighted centring: private API
Functions
PortfolioOptimisers.centring_terms — Function
centring_terms(c::AbstractCentring, n::Integer) -> Any
Count of the terms that the valid returns of an asset give to a moment.
Arguments
c: The centring.n: Count of the valid returns of the asset.
Returns
k::Integer:nless the lag ofc, floored at zero.
Related
PortfolioOptimisers.centring_ready — Function
centring_ready(
c::AbstractCentring,
n::Integer,
min_obs::Integer
) -> Any
Whether an asset has enough valid returns for its moment to be reported.
The asset needs min_obs valid returns and at least one term, so under EstimatedCentring an asset of one valid return is not ready at any min_obs.
Arguments
c: The centring.n: Count of the valid returns of the asset.min_obs: The minimum count of valid returns.
Returns
flag::Bool: Whether the asset is ready.
Related
PortfolioOptimisers.centring_overlap! — Function
centring_overlap!(::Nothing, valid::AbstractVector{<:Bool}, decay::Number)
centring_overlap!(P::MatNum, valid::AbstractVector{<:Bool}, decay::Number)Folds one observation into the overlap of the locations.
A valid return of an asset ages each weight of its location by decay, and a return that both assets of a pair hold adds the product of its two new weights.
\[\begin{align} P_{ij} &\leftarrow \lambda^{v_i + v_j} P_{ij} + v_i v_j (1 - \lambda)^2\,. \end{align}\]
Where:
- $\lambda$:
decay, the decay factor of the exponentially weighted recursion. - $v_i$: One where asset $i$ is valid at the observation, zero otherwise.
Returns
P: The overlap after the observation, written in place, ornothing.
Related
PortfolioOptimisers.centring_reset! — Function
centring_reset!(::Nothing, idx::AbstractVector{<:Bool})
centring_reset!(P::MatNum, idx::AbstractVector{<:Bool})Zeroes the rows and the columns of the overlap of the assets that reset.
Returns
P: The overlap, written in place, ornothing.
Related
PortfolioOptimisers.centring_pair_factor — Function
centring_pair_factor(::Nothing, obs_count::AbstractVector{<:Integer}, decay::Number,
idx::AbstractVector{<:Integer})
centring_pair_factor(P::MatNum, obs_count::AbstractVector{<:Integer}, decay::Number,
idx::AbstractVector{<:Integer})Exact factor of the mean of the product of the deviations of each pair of a block, in units of the covariance of the pair.
The factor is $1 + c_{ij}$, with $c_{ij} = P_{ij} / (S_{1,i}\, S_{1,j})$ and $S_{1,i} = 1 - \lambda^{n_i}$, the sum of the weights of the location of asset $i$. A pair whose asset holds no return has no factor, and takes one. A pre-centred estimator holds no overlap, and its factor is one.
Arguments
P: The overlap of the locations before the observation, ornothing.obs_count: Count of the valid returns of each asset before the observation.decay: Decay of the locations.idx: Index of the assets of the block.
Returns
F::Union{<:Number, <:MatNum}: The matrix of the factors of the block, or one.
Related
PortfolioOptimisers.centring_lag_record — Function
centring_lag_record(
obs_count::AbstractVector{<:Integer},
valid::AbstractVector{<:Bool},
P::Union{Nothing, AbstractMatrix{<:Union{var"#s152", var"#s69"} where {var"#s152"<:Number, var"#s69"<:AbstractJuMPScalar}}}
) -> NamedTuple{(:obs_count, :valid, :P), <:Tuple{Any, BitVector, Any}}
Record of one lagged observation, which the factor of a HAC product reads.
The HAC term of an observation adds the products of its deviations with the deviations of the lagged observations. Under EstimatedCentring such a product has a non-zero mean, which reads the counts of the lagged observation, the assets valid there, and the overlap of the locations before it.
Arguments
obs_count: Count of the valid returns of each asset before the lagged observation.valid: Mask of the assets valid at the lagged observation.P: The overlap of the locations before the lagged observation, ornothingwhere the estimator reads the diagonal alone.
Returns
(; obs_count, valid, P)::NamedTuple: Fresh copies of the three arguments.
Related
PortfolioOptimisers.centring_lag_push! — Function
centring_lag_push!(::Nothing, obs_count::AbstractVector{<:Integer},
valid::AbstractVector{<:Bool}, P::Option{<:MatNum})
centring_lag_push!(records::DataStructures.CircularBuffer,
obs_count::AbstractVector{<:Integer}, valid::AbstractVector{<:Bool},
P::Option{<:MatNum})Pushes the record of one observation into the buffer of lagged records.
Arguments
obs_count: Count of the valid returns of each asset before the observation.valid: Mask of the assets valid at the observation.P: The overlap of the locations before the observation, ornothing.
Returns
records: The buffer, ornothing.
Related
PortfolioOptimisers.hac_buffer_reset! — Function
hac_buffer_reset!(::Nothing, idx::AbstractVector{<:Bool})
hac_buffer_reset!(buffer::DataStructures.CircularBuffer, idx::AbstractVector{<:Bool})Blanks the lagged deviations of the assets that reset.
A reset discards the history of an asset, so a deviation from before it is no term of a later HAC product. The method sets the entries of each such asset to NaN in every lagged observation, which the HAC term reads as zero.
Returns
buffer: The buffer, written in place, ornothing.
Related
PortfolioOptimisers.centring_lag_reset! — Function
centring_lag_reset!(::Nothing, idx::AbstractVector{<:Bool})
centring_lag_reset!(records, idx::AbstractVector{<:Bool})Marks the assets that reset as absent from every lagged record.
A reset discards the history of an asset, so its location no longer holds a lagged return, and a deviation from before the reset is no term of a later HAC product. The method sets the count of each such asset to -1 in every record.
Returns
records: The records, written in place, ornothing.
Related