Package tech.nmfin.returns
Enum ReturnsCalculators
- java.lang.Object
-
- java.lang.Enum<ReturnsCalculators>
-
- tech.nmfin.returns.ReturnsCalculators
-
- All Implemented Interfaces:
Serializable
,Comparable<ReturnsCalculators>
,ReturnsCalculator
public enum ReturnsCalculators extends Enum<ReturnsCalculators> implements ReturnsCalculator
Various ways of return calculations.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract double
computePrice(double px0, double r)
Computes the next price after a return.abstract double
computeReturn(double v1, double v2)
Computes the portfolio return.static ReturnsCalculators
valueOf(String name)
Returns the enum constant of this type with the specified name.static ReturnsCalculators[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
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 nameNullPointerException
- 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 interfaceReturnsCalculator
- Parameters:
v1
- the beginning value of the portfoliov2
- 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 interfaceReturnsCalculator
- Parameters:
px0
- the original pricer
- the return- Returns:
- the new price
-
-