Enum ReturnsCalculators

    • Enum Constant Detail

      • ABSOLUTE

        public static final ReturnsCalculators ABSOLUTE
        The return is defined as the difference between the values of the portfolio. i.e.,
        r = v2 - v1
      • SIMPLE

        public static final ReturnsCalculators SIMPLE
        The return is defined as the absolute return over the original value. i.e.,
        r = (v2 / v1) - 1
      • LOG

        public static final ReturnsCalculators LOG
        The return is defined as the natural logarithm of the ratio v2/v1. i.e.,
        r = log(v2 / v1)
    • Method Detail

      • values

        public static ReturnsCalculators[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ReturnsCalculators c : ReturnsCalculators.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ReturnsCalculators valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • computeReturn

        public abstract double computeReturn​(double v1,
                                             double v2)
        Description copied from interface: ReturnsCalculator
        Computes the portfolio return.
        Specified by:
        computeReturn in interface ReturnsCalculator
        Parameters:
        v1 - the beginning value of the portfolio
        v2 - the ending value of the portfolio
        Returns:
        the return value
      • computePrice

        public abstract double computePrice​(double px0,
                                            double r)
        Description copied from interface: ReturnsCalculator
        Computes the next price after a return.
        Specified by:
        computePrice in interface ReturnsCalculator
        Parameters:
        px0 - the original price
        r - the return
        Returns:
        the new price