Interface OptionFunction
-
- All Known Implementing Classes:
ConstantContinuousSingleBarrierKnockoutFunction
,EuropeanVanillaOptionFunction
public interface OptionFunction
Option function interface used in trinomial tree option pricing.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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.default DoubleArray
getNextOptionValues(double discountFactor, DoubleMatrix transitionProbability, DoubleArray stateValue, DoubleArray value, int i)
Computes the option values in the intermediate nodes.int
getNumberOfSteps()
Obtains number of time steps.default DoubleArray
getPayoffAtExpiryTrinomial(double spot, double downFactor, double middleFactor)
Computes payoff at expiry for trinomial tree.DoubleArray
getPayoffAtExpiryTrinomial(DoubleArray stateValue)
Computes payoff at expiry for trinomial tree.double
getTimeToExpiry()
Obtains time to expiry.
-
-
-
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 returnedDoubleArray
has the size2 * n + 1
.- Parameters:
spot
- the spotdownFactor
- the down factormiddleFactor
- 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 layersupProbability
- the up probabilitymiddleProbability
- the middle probabilitydownProbability
- the down probabilityvalue
- the option values in the (i+1)-th layerspot
- the spotdownFactor
- the down factormiddleFactor
- the middle factori
- 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 layerstransitionProbability
- the transition probabilitystateValue
- the state valuevalue
- the option valuei
- the step number for which the next option values are computed- Returns:
- the option values in the i-th layer
-
-