Example #1
0
        //! default theta calculation for Black-Scholes options
        public static double blackScholesTheta(GeneralizedBlackScholesProcess p, double value, double delta, double gamma)
        {
            double u = p.stateVariable().currentLink().value();
            double r = p.riskFreeRate().currentLink().zeroRate(0.0, Compounding.Continuous).rate();
            double q = p.dividendYield().currentLink().zeroRate(0.0, Compounding.Continuous).rate();
            double v = p.localVolatility().currentLink().localVol(0.0, u, false);

            return r *value -(r-q)*u *delta - 0.5 *v *v *u *u *gamma;
        }
        //! default theta calculation for Black-Scholes options
        public static double blackScholesTheta(GeneralizedBlackScholesProcess p, double value, double delta, double gamma)
        {
            double u = p.stateVariable().currentLink().value();
            double r = p.riskFreeRate().currentLink().zeroRate(0.0, Compounding.Continuous).rate();
            double q = p.dividendYield().currentLink().zeroRate(0.0, Compounding.Continuous).rate();
            double v = p.localVolatility().currentLink().localVol(0.0, u, false);

            return(r * value - (r - q) * u * delta - 0.5 * v * v * u * u * gamma);
        }
Example #3
0
 public FdmBlackScholesOp(FdmMesher mesher,
                          GeneralizedBlackScholesProcess bsProcess,
                          double strike,
                          bool localVol = false,
                          double?illegalLocalVolOverwrite = null,
                          int direction = 0)
 {
     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;
 }