EuropeanOptionDeltaPathwise.java
package net.finmath.montecarlo.assetderivativevaluation.products;
/*
* (c) Copyright Christian P. Fries, Germany. Contact: email@christian-fries.de.
*
* Created on 12.02.2013
*/
import java.util.logging.Logger;
import net.finmath.exception.CalculationException;
import net.finmath.montecarlo.assetderivativevaluation.AssetModelMonteCarloSimulationModel;
import net.finmath.montecarlo.assetderivativevaluation.MonteCarloAssetModel;
import net.finmath.montecarlo.assetderivativevaluation.MonteCarloBlackScholesModel;
import net.finmath.montecarlo.assetderivativevaluation.models.BlackScholesModel;
import net.finmath.stochastic.RandomVariable;
import net.finmath.stochastic.Scalar;
/**
* Implements calculation of the delta of a European option using the path-wise method,
* assuming that the underlying follows a model where d S(T)/d S(0) = S(T)/S(0),
* e.g., Black-Scholes.
*
* @author Christian Fries
* @version 1.1
* @since finmath-lib 4.1.0
*/
public class EuropeanOptionDeltaPathwise extends AbstractAssetMonteCarloProduct {
private final double maturity;
private final double strike;
/**
* Construct a product representing an European option on an asset S (where S the asset with index 0 from the model - single asset case).
*
* @param strike The strike K in the option payoff max(S(T)-K,0).
* @param maturity The maturity T in the option payoff max(S(T)-K,0)
*/
public EuropeanOptionDeltaPathwise(final double maturity, final double strike) {
super();
this.maturity = maturity;
this.strike = strike;
}
/**
* This method returns the value random variable of the product within the specified model, evaluated at a given evalutationTime.
* Note: For a lattice this is often the value conditional to evalutationTime, for a Monte-Carlo simulation this is the (sum of) value discounted to evaluation time.
* Cashflows prior evaluationTime are not considered.
*
* @param evaluationTime The time on which this products value should be observed.
* @param model The model used to price the product.
* @return The random variable representing the value of the product discounted to evaluation time
* @throws net.finmath.exception.CalculationException Thrown if the valuation fails, specific cause may be available via the <code>cause()</code> method.
*/
@Override
public RandomVariable getValue(final double evaluationTime, final AssetModelMonteCarloSimulationModel model) throws CalculationException {
if(!MonteCarloBlackScholesModel.class.isInstance(model) &&
(MonteCarloAssetModel.class.isInstance(model) && !BlackScholesModel.class.isInstance(((MonteCarloAssetModel)model).getModel()))) {
Logger.getLogger("net.finmath").warning("This method assumes a Black-Scholes type model (MonteCarloBlackScholesModel).");
}
// Get S(T), S(0)
final RandomVariable underlyingAtMaturity = model.getAssetValue(maturity,0);
final RandomVariable underlyingAtEvalTime = model.getAssetValue(evaluationTime,0);
// The "payoff": values = indicator(S(T)-K) * S(T)/S(0)
final RandomVariable trigger = underlyingAtMaturity.sub(strike);
RandomVariable values = trigger.choose(underlyingAtMaturity, new Scalar(0.0)).div(underlyingAtEvalTime);
// Discounting...
final RandomVariable numeraireAtMaturity = model.getNumeraire(maturity);
final RandomVariable monteCarloWeights = model.getMonteCarloWeights(maturity);
values = values.div(numeraireAtMaturity).mult(monteCarloWeights);
// ...to evaluation time.
final RandomVariable numeraireAtEvalTime = model.getNumeraire(evaluationTime);
final RandomVariable monteCarloWeightsAtEvalTime = model.getMonteCarloWeights(evaluationTime);
values = values.mult(numeraireAtEvalTime).div(monteCarloWeightsAtEvalTime);
return values;
}
}