Interface OptionFunction

    • Method Detail

      • getTimeToExpiry

        double getTimeToExpiry()
        Obtains time to expiry.
        Returns:
        time to expiry
      • getNumberOfSteps

        int getNumberOfSteps()
        Obtains number of time steps.
        Returns:
        number of time steps
      • getPayoffAtExpiryTrinomial

        default DoubleArray getPayoffAtExpiryTrinomial​(double spot,
                                                       double downFactor,
                                                       double middleFactor)
        Computes payoff at expiry for trinomial tree.

        The payoff values for individual nodes at expiry are computed. If trinomial tree has n steps, the returned DoubleArray has the size 2 * n + 1.

        Parameters:
        spot - the spot
        downFactor - the down factor
        middleFactor - the middle factor
        Returns:
        the payoff at expiry
      • getPayoffAtExpiryTrinomial

        DoubleArray getPayoffAtExpiryTrinomial​(DoubleArray stateValue)
        Computes payoff at expiry for trinomial tree.

        The payoff values for individual nodes at expiry are computed from state values at the final layer. For example, the state values represent underlying prices of an option at respective nodes.

        Parameters:
        stateValue - the state values
        Returns:
        the payoff at expiry
      • getNextOptionValues

        default DoubleArray getNextOptionValues​(double discountFactor,
                                                double upProbability,
                                                double middleProbability,
                                                double downProbability,
                                                DoubleArray value,
                                                double spot,
                                                double downFactor,
                                                double middleFactor,
                                                int i)
        Computes the option values in the intermediate nodes.

        Given a set of option values in the (i+1)-th layer, option values in the i-th layer are derived. For an option with path-dependence, getNextOptionValues(double, DoubleMatrix, DoubleArray, DoubleArray, int) should be overridden rather than this method.

        The size of values must be (2*i+3). However, this is not checked because of its repeated usage.

        Parameters:
        discountFactor - the discount factor between the two layers
        upProbability - the up probability
        middleProbability - the middle probability
        downProbability - the down probability
        value - the option values in the (i+1)-th layer
        spot - the spot
        downFactor - the down factor
        middleFactor - the middle factor
        i - the step number for which the next option values are computed
        Returns:
        the option values in the i-th layer
      • getNextOptionValues

        default DoubleArray getNextOptionValues​(double discountFactor,
                                                DoubleMatrix transitionProbability,
                                                DoubleArray stateValue,
                                                DoubleArray value,
                                                int i)
        Computes the option values in the intermediate nodes.

        Given a set of option values in the (i+1)-th layer, option values in the i-th layer are derived. The down, middle and up probabilities of the j-th lowest node are stored in the {i,0}, {i,1}, {i,2} components of transitionProbability, respectively.

        For an option with path-dependence, this method should be overridden.

        Parameters:
        discountFactor - the discount factor between the two layers
        transitionProbability - the transition probability
        stateValue - the state value
        value - the option value
        i - the step number for which the next option values are computed
        Returns:
        the option values in the i-th layer