Login  Register

BlackCalculator greeks does not match the formula in wiki

Posted by SteveGe on Aug 28, 2014; 9:51am
URL: http://quantlib.414.s1.nabble.com/BlackCalculator-greeks-does-not-match-the-formula-in-wiki-tp15802.html

Hi all,

I am confused with the BlackCalculator. It is different from the formula in wiki.
http://en.wikipedia.org/wiki/Greeks_(finance)

i.e Delta is simply N(d).
but the below code is so complex. the same for theta and gamma.  I am wondering because I am not able to match the thetaPerDay with bloomberg. So I am not sure whether there are bug in the theta formula.
but without understand the implementation, I am not able to modify it.
 Or is Bloomberg number simply wrong ?
  Real BlackCalculator::delta(Real spot) const {

        QL_REQUIRE(spot > 0.0, "positive spot value required: " <<
                   spot << " not allowed");

        Real DforwardDs = forward_ / spot;

        Real temp = stdDev_*spot;
        Real DalphaDs = DalphaDd1_/temp;
        Real DbetaDs  = DbetaDd2_/temp;
        Real temp2 = DalphaDs * forward_ + alpha_ * DforwardDs
                      +DbetaDs  * x_       + beta_  * DxDs_;

        return discount_ * temp2;
    }



@Test
    public void theta() {
        double tightTolerance = 0.01;
        double strike = 6.2686;
        double spot = 6.2271;
        double forward = 6.2686;
        double time = maturity(186);
        double volatility = 2.5 / 100;
        double domesticDiscount = discountFactor(4.8, 184, 365.0); // 4.8% 186d
        RawFxOption rawFxOption = new RawFxOption(Put, strike, spot, forward, time, volatility, domesticDiscount);
        System.out.println(rawFxOption.price());
        System.out.println(rawFxOption.decay());
        System.out.println(rawFxOption.vega());
        System.out.println(rawFxOption.gamma());
        System.out.println(rawFxOption.rho());
        //Assert.assertEquals(10719.47, rawFxOption.price() * 1E6, tightTolerance);
    }

    private double maturity(double days) {
        return days / 365.0;
    }

    private double discountFactor(double ratePercent, int days, double daysOfYear) {
        return 1.0 / (1 + ratePercent / 100.0 * days / daysOfYear);
    }

Above code produce   -0.00104534018 for theta per Year whereas bloomberg has -110.92 CNYper day for 1M USD
0.04357539169831881
-0.0011045340186808972
0.017429694068779016
0.2197069705587712
-1.5705728003534443

Please help me.

Thanks in advance.