Returns - Functions

TFire.compound_returnFunction
compound_return(c::Collection, steps::Integer, fut_price_type::Function=FutureAdjClose; flat::Bool=false)

Calculates the compound return from each evaluation date in c over steps time steps.

fut_price_type specifies the type of future price data to extract from the Collection. Default is FutureAdjClose.

If flat==true gives the returns in a flat vector, otherwise gives the returns in a vector of vectors, in the same structure as CollectionDataViews.

source
TFire.compound_returnFunction
compound_return(c::Collection, fut_price_type::Function=FutureAdjClose; flat::Bool=false)

Calculates the compound return for Collection c over its samples.

fut_price_type specifies the type of future price data to extract from the Collection. Default is FutureAdjClose.

Returns a vector of vectors of vectors containing the compound returns for each sample. The outermost vector matches the Assets. The middle vector matches the samples. The innermost vector matches the number of time steps.

If flat=true, flattens the result into a vector of vectors instead of a vector of vectors of vectors.

source
TFire.compound_returnMethod
compound_return(dv::T)::Vector{Vector{Float64}} where {T<:FuturePriceView}

Calculates the compound return for FuturePriceView dv.

Returns a vector of vectors containing the compound returns for each sample. The outer vector matches the number of samples. The inner vector matches the number of time steps per sample.

source
TFire.compound_returnMethod
compound_return(cdv::CDV{T})::Vector{Vector{Vector{Float64}}} where T <: FuturePriceView

Calculates the compound return for a CollectionDataView of FuturePriceView: cdv.

Returns a vector of vectors of vectors containing the compound returns for each sample. The outermost vector matches the Assets. The middle vector matches the samples. The innermost vector matches the number of time steps.

source
TFire.compound_returnMethod
compound_return(fcdv::FlatCDV{T})::Vector{Vector{Float64}} where T <: FuturePriceView

Calculates the compound return for a FlatCollectionDataView of FuturePriceView: cdv.

The outer vector matches the number of samples over all Assets. The inner vector matches the number of time steps per sample.

source
TFire.compound_returnMethod
compound_return(cdv::CDV{T}, steps::Integer)::Vector{Vector{Float64}} where T <: FuturePriceView

Calculates the compound return for each collection data view (CDV) in cdv over steps time steps. Returns a vector of vectors containing the compound returns for each sample in the CDV.

source
TFire.compound_returnMethod
compound_return(fcdv::FlatCDV{T}, steps::Integer)::Vector{Float64} where T <: FuturePriceView

Calculates the compound return for each sample in the flattened collection data view fcdv over steps time steps. Returns a flattened vector containing the compound returns.

source
TFire.compound_returnMethod
compound_return(dv::T, steps::Integer)::Vector{Float64} where T <: FuturePriceView

Calculates the compound return for each element in dv over steps time steps. Returns a vector with the compound return for each sample.

source
TFire.compound_return_envelopeFunction
compound_return_envelope(collection::Collection, steps, fut_price_type::Function=FutureAdjClose)

Returns bestreturns, worstreturns

Calculate the envelope of best and worst compound returns for the given Collection over steps into the future. fut_price_type specifies the type of future adjusted close price to use in the calculation.

Returns the arithmetic mean best and mean worst cumulative returns as arrays where the first element of respective array is the best respective worst single return of one sample, the second element is the mean of the best and second best respective worst and second worst, etc. up to the last element which is the mean best respective worst over all samples.

source
TFire.mean_compound_returnFunction
mean_compound_return(collection::Collection, steps::Integer, fut_price_type::Function=FutureAdjClose)

Calculates the mean compound return for fr, a vector of vectors of future returns, for steps number of steps. Returns a vector where element i is the mean compound return after i steps of all samples that has i available steps in the future returns.

The same function with equally weighted steps exists as meanlikeweightedcompoundreturn_total()

source
TFire.mean_like_weighted_compound_returnFunction
mean_like_weighted_compound_return(collection::Collection, steps, fut_price_type::Type{T}=FutureAdjClose) where T <: AbstractFutureAdjClose

Calculates the mean compound return for fr, a vector of vectors of future returns, for steps number of steps. Returns a vector where element i is the mean compound return after i steps of all samples that has i available steps in the future returns.

The return is calculated as if the "portfolio" was reweighted to equally weighted each step. The same function without equally weighted steps exists as meancompoundreturn_total()

source
TFire.mean_like_weighted_step_returnFunction
mean_like_weighted_step_return(collection::Collection, steps::Integer, fut_price_type::Function=FutureAdjClose)

Calculates the mean-like weighted step returns for a collection of future returns, for the specified number of steps.

The mean-like weighted step returns are calculated by first computing the mean-like weighted compound returns using mean_like_weighted_compound_return, and then deriving the step returns from the compound returns.

Args: collection (Collection): The collection of future returns. steps (Integer): The number of steps to calculate the step returns for. futpricetype (Function): The function to use to extract the future prices from the collection. Defaults to FutureAdjClose.

Returns: Vector{Float64}: A vector of step returns, where the i-th element is the mean-like weighted step return after i steps.

source
TFire.step_returnFunction
step_return(c::Collection, ind::Integer, fut_price_type::Function=FutureAdjClose; flat::Bool=false)

Calculate the step return between time indices ind-1 and ind for each asset in the Collection c. fut_price_type specifies the type of future price data to use, defaulting to FutureAdjClose.

If flat=true, the data is flattened and a flat vector is returned.

Returns a vector or vector of vectors of returns with shape matching the input data.

source
TFire.step_returnMethod
step_return(cdv::CDV{T}, ind::Integer)::Vector{Vector{Float64}} where T <: FuturePriceView

Takes a CollectionDataView of an FuturePriceView and calculate the step return between time indices ind-1 and ind.

Returns a vector of vectors on the same format as a CollectionDataView.

source
TFire.step_returnMethod
step_return(fcdv::FlatCDV{T}, ind::Integer)::Vector{Float64} where T <: FuturePriceView

Takes a FlatCollectionDataView of an FuturePriceView and calculate the step return between time indices ind-1 and ind.

Returns a vector of the same format as a FlatCollectionDataView.

source
TFire.step_returnMethod
step_return(dv::T, ind::Integer)::Vector{Float64} where T <: FuturePriceView

Takes a FuturePriceView and calculate the step return between time indices ind-1 and ind.

Returns a vector with indices corespoding to the samples in dv.

source