public FdmHestonEquityPart(FdmMesher mesher, YieldTermStructure rTS, YieldTermStructure qTS, FdmQuantoHelper quantoHelper = null, LocalVolTermStructure leverageFct = null) { varianceValues_ = new Vector(0.5 * mesher.locations(1)); dxMap_ = new FirstDerivativeOp(0, mesher); dxxMap_ = new SecondDerivativeOp(0, mesher).mult(0.5 * mesher.locations(1)); mapT_ = new TripleBandLinearOp(0, mesher); mesher_ = mesher; rTS_ = rTS; qTS_ = qTS; quantoHelper_ = quantoHelper; leverageFct_ = leverageFct; // on the boundary s_min and s_max the second derivative // d^2V/dS^2 is zero and due to Ito's Lemma the variance term // in the drift should vanish. FdmLinearOpLayout layout = mesher_.layout(); FdmLinearOpIterator endIter = layout.end(); for (FdmLinearOpIterator iter = layout.begin(); iter != endIter; ++iter) { if (iter.coordinates()[0] == 0 || iter.coordinates()[0] == layout.dim()[0] - 1) { varianceValues_[iter.index()] = 0.0; } } volatilityValues_ = Vector.Sqrt(2 * varianceValues_); }
public SecondDerivativeOp(SecondDerivativeOp rhs) : base(rhs.direction_, rhs.mesher_) { lower_ = rhs.lower_; diag_ = rhs.diag_; upper_ = rhs.upper_; }
public FdmHestonVariancePart( FdmMesher mesher, YieldTermStructure rTS, double sigma, double kappa, double theta) { dyMap_ = new SecondDerivativeOp(1, mesher) .mult(0.5 * sigma * sigma * mesher.locations(1)) .add(new FirstDerivativeOp(1, mesher) .mult(kappa * (theta - mesher.locations(1)))); mapT_ = new TripleBandLinearOp(1, mesher); rTS_ = rTS; }
public FdmBlackScholesOp(FdmMesher mesher, GeneralizedBlackScholesProcess bsProcess, double strike, bool localVol = false, double?illegalLocalVolOverwrite = null, int direction = 0, FdmQuantoHelper quantoHelper = null) { mesher_ = mesher; rTS_ = bsProcess.riskFreeRate().currentLink(); qTS_ = bsProcess.dividendYield().currentLink(); volTS_ = bsProcess.blackVolatility().currentLink(); localVol_ = (localVol) ? bsProcess.localVolatility().currentLink() : null; x_ = (localVol) ? new Vector(Vector.Exp(mesher.locations(direction))) : null; dxMap_ = new FirstDerivativeOp(direction, mesher); dxxMap_ = new SecondDerivativeOp(direction, mesher); mapT_ = new TripleBandLinearOp(direction, mesher); strike_ = strike; illegalLocalVolOverwrite_ = illegalLocalVolOverwrite; direction_ = direction; quantoHelper_ = quantoHelper; }