Skip to content
13

Greedy allocation

PortfolioOptimisers.GreedyAllocationResult Type
julia
struct GreedyAllocationResult{__T_oe, __T_retcode, __T_shares, __T_cost, __T_w, __T_cash, __T_fb} <: FiniteAllocationOptimisationResult

Result type for Greedy Allocation portfolio optimisation.

Fields

  • oe: Type of the optimisation estimator that produced this result.

  • retcode: Optimisation return code.

  • shares: Vector of shares allocated to each asset.

  • cost: Total cost of the allocated shares.

  • w: Realised portfolio weights.

  • cash: Remaining uninvested cash.

  • fb: Fallback result.

Related

source
PortfolioOptimisers.GreedyAllocation Type
julia
struct GreedyAllocation{__T_unit, __T_args, __T_kwargs, __T_fb} <: FiniteAllocationOptimisationEstimator

Greedy Allocation portfolio optimiser.

GreedyAllocation converts continuous portfolio weights to discrete share quantities using a greedy two-pass allocation: first round shares to the nearest unit multiple, then iteratively buy remaining shares with leftover cash in order of largest weight.

Fields

  • unit: Minimum share purchase unit (e.g., 1 for whole shares, 0.01 for fractional shares).

  • args: Additional positional arguments forwarded to round.

  • kwargs: Additional keyword arguments forwarded to round.

  • fb: Fallback allocator.

Constructors

julia
GreedyAllocation(;
    unit::Number = 1,
    args::Tuple = (),
    kwargs::NamedTuple = (;),
    fb::Option{<:FOptE_FOpt} = nothing
) -> GreedyAllocation

Keywords correspond to the struct's fields.

Examples

julia
julia> GreedyAllocation()
GreedyAllocation
    unit ┼ Int64: 1
    args ┼ Tuple{}: ()
  kwargs ┼ @NamedTuple{}: NamedTuple()
      fb ┴ nothing

Related

source
PortfolioOptimisers.optimise Function
julia
optimise(ga::GreedyAllocation{<:Any, <:Any, <:Any, Nothing}, w::VecNum, p::VecNum,
         cash::Number = 1e6, T::Option{<:Number} = nothing,
         fees::Option{<:Fees} = nothing; kwargs...) -> GreedyAllocationResult

Arguments

  • da: The discrete allocation optimiser to use.

  • w: Portfolio weights vector assets × 1.

  • p: The prices of the assets in the same order as w.

  • cash: The initial cash balance.

  • T: The time horizon for the optimisation. Used to adjust the initial cash balance according to the fees charged on the portfolio for the time horizon.

  • fees: The fees to apply to the portfolio.

  • kwargs: Additional keyword arguments passed to the optimisation function.

source