Class ValueSchedule

  • All Implemented Interfaces:
    Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class ValueSchedule
    extends Object
    implements org.joda.beans.ImmutableBean, Serializable
    A value that can vary over time.

    This represents a single initial value and any adjustments over the lifetime of a trade. Adjustments may be specified in absolute or relative terms.

    The adjustments may be specified as individual steps or as a sequence of steps. An individual step is a change that occurs at a specific date, identified either by the date or the index within the schedule. A sequence of steps consists of a start date, end date and frequency, with the same change applying many times. All changes must occur on dates that are period boundaries in the specified schedule.

    It is possible to specify both individual steps and a sequence, however this is not recommended. It it is done, then the individual steps and sequence steps must resolve to different dates.

    The value is specified as a double with the context adding additional meaning. If the value represents an amount of money then the currency is specified separately. If the value represents a rate then a 5% rate is expressed as 0.05.

    See Also:
    Serialized Form
    • Field Detail

      • ALWAYS_0

        public static final ValueSchedule ALWAYS_0
        A value schedule that always has the value zero.
      • ALWAYS_1

        public static final ValueSchedule ALWAYS_1
        A value schedule that always has the value one.
    • Method Detail

      • of

        public static ValueSchedule of​(double value)
        Obtains an instance from a single value that does not change over time.
        Parameters:
        value - a single value that does not change over time
        Returns:
        the value schedule
      • of

        public static ValueSchedule of​(double initialValue,
                                       ValueStep... steps)
        Obtains an instance from an initial value and a list of changes.

        Each step fully defines a single change in the value. The date of each change can be specified as an absolute date or in relative terms.

        Parameters:
        initialValue - the initial value used for the first period
        steps - the full definition of how the value changes over time
        Returns:
        the value schedule
      • of

        public static ValueSchedule of​(double initialValue,
                                       List<ValueStep> steps)
        Obtains an instance from an initial value and a list of changes.

        Each step fully defines a single change in the value. The date of each change can be specified as an absolute date or in relative terms.

        Parameters:
        initialValue - the initial value used for the first period
        steps - the full definition of how the value changes over time
        Returns:
        the value schedule
      • of

        public static ValueSchedule of​(double initialValue,
                                       ValueStepSequence stepSequence)
        Obtains an instance from an initial value and a sequence of steps.

        The sequence defines changes from one date to another date using a frequency. For example, the value might change every year from 2011-06-01 to 2015-06-01.

        Parameters:
        initialValue - the initial value used for the first period
        stepSequence - the full definition of how the value changes over time
        Returns:
        the value schedule
      • resolveValues

        public DoubleArray resolveValues​(Schedule schedule)
        Resolves the value and adjustments against a specific schedule.

        This converts a schedule into a list of values, one for each schedule period.

        Parameters:
        schedule - the schedule
        Returns:
        the values, one for each schedule period
      • meta

        public static ValueSchedule.Meta meta()
        The meta-bean for ValueSchedule.
        Returns:
        the meta-bean, not null
      • builder

        public static ValueSchedule.Builder builder()
        Returns a builder used to create an instance of the bean.
        Returns:
        the builder, not null
      • metaBean

        public ValueSchedule.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getInitialValue

        public double getInitialValue()
        Gets the initial value.

        This is used for the lifetime of the trade unless specifically varied.

        Returns:
        the value of the property
      • getSteps

        public List<ValueStep> getSteps()
        Gets the steps defining the change in the value.

        Each step consists of a key locating the date of the change and the adjustment that occurs.

        Returns:
        the value of the property, not null
      • getStepSequence

        public Optional<ValueStepSequence> getStepSequence()
        Gets the sequence of steps changing the value.

        This allows a regular pattern of steps to be encoded. All step dates must be unique, thus the list of steps must not contain any date implied by this sequence.

        Returns:
        the optional value of the property, not null
      • toBuilder

        public ValueSchedule.Builder toBuilder()
        Returns a builder that allows this bean to be mutated.
        Returns:
        the mutable builder, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object