Class MarkowitzModel

    • Field Detail

      • _0_0

        private static final double _0_0
      • INIT

        private static final double INIT
      • MAX

        private static final double MAX
      • MIN

        private static final double MIN
      • TARGET_CONTEXT

        private static final NumberContext TARGET_CONTEXT
      • myConstraints

        private final java.util.HashMap<int[],​LowerUpper> myConstraints
      • myTargetReturn

        private java.math.BigDecimal myTargetReturn
      • myTargetVariance

        private java.math.BigDecimal myTargetVariance
    • Method Detail

      • addConstraint

        public LowerUpper addConstraint​(java.math.BigDecimal lowerLimit,
                                        java.math.BigDecimal upperLimit,
                                        int... assetIndeces)
        Will add a constraint on the sum of the asset weights specified by the asset indices. Either (but not both) of the limits may be null.
      • clearAllConstraints

        public void clearAllConstraints()
      • setLowerLimit

        public void setLowerLimit​(int assetIndex,
                                  java.math.BigDecimal lowerLimit)
      • setTargetReturn

        public void setTargetReturn​(java.math.BigDecimal targetReturn)

        Will set the target return to whatever you input and the target variance to null.

        Setting the target return implies that you disregard the risk aversion factor and want the minimum risk portfolio with return that is equal to or as close to the target as possible.

        There is a performance penalty for setting a target return as the underlying optimisation model has to be solved several (many) times with different pararmeters (different risk aversion factors).

        Setting a target return (or variance) is not recommnded. It's much better to simply modify the risk aversion factor.

        See Also:
        setTargetVariance(BigDecimal)
      • setTargetVariance

        public void setTargetVariance​(java.math.BigDecimal targetVariance)

        Will set the target variance to whatever you input and the target return to null.

        Setting the target variance implies that you disregard the risk aversion factor and want the maximum return portfolio with risk that is equal to or as close to the target as possible.

        There is a performance penalty for setting a target variance as the underlying optimisation model has to be solved several (many) times with different pararmeters (different risk aversion factors).

        Setting a target variance is not recommnded. It's much better to modify the risk aversion factor.

        See Also:
        setTargetReturn(BigDecimal)
      • setUpperLimit

        public void setUpperLimit​(int assetIndex,
                                  java.math.BigDecimal upperLimit)
      • generateOptimisationModel

        private ExpressionsBasedModel generateOptimisationModel​(double riskAversion)
      • calculatePortfolioVariance

        Scalar<?> calculatePortfolioVariance​(Access1D<?> weightsVctr)