Exemple #1
0
    def testBachelierImpliedVol(self):
        forward = 1.0
        bpvol = 0.01
        tte = 10.0
        r = 0.03

        dList = [-3.0, -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0, 3.0]

        for d in dList:
            strike = forward + d * bpvol * math.sqrt(tte)
            callPrem = bachelierFormula(OptionType.Call, strike, forward,
                                        bpvol * math.sqrt(tte),
                                        math.exp(-r * tte))
            impliedBpVol = bachelierFormulaImpliedVol(OptionType.Call, strike,
                                                      forward, tte, callPrem,
                                                      math.exp(-r * tte))
            self.assertAlmostEqual(impliedBpVol, bpvol, 12)

            callPrem = bachelierFormula(OptionType.Put, strike, forward,
                                        bpvol * math.sqrt(tte),
                                        math.exp(-r * tte))
            impliedBpVol = bachelierFormulaImpliedVol(OptionType.Put, strike,
                                                      forward, tte, callPrem,
                                                      math.exp(-r * tte))
            self.assertAlmostEqual(impliedBpVol, bpvol, 12)
    def testBachelierBasics(self):
        strike = 1.0
        forward = 1.2
        discount = 0.95

        expected = discount * (forward - strike)
        calculated = bachelierFormula(OptionType.Call, strike, forward, 0.0, discount)
        self.assertAlmostEqual(expected, calculated, 15)
Exemple #3
0
    def testBachelierBasics(self):
        strike = 1.0
        forward = 1.2
        discount = 0.95

        expected = discount * (forward - strike)
        calculated = bachelierFormula(OptionType.Call, strike, forward, 0.0,
                                      discount)
        self.assertAlmostEqual(expected, calculated, 15)
    def testBachelierImpliedVol(self):
        forward = 1.0
        bpvol = 0.01
        tte = 10.0
        r = 0.03

        dList = [-3.0, -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0, 3.0]

        for d in dList:
            strike = forward + d * bpvol * math.sqrt(tte)
            callPrem = bachelierFormula(OptionType.Call, strike, forward, bpvol * math.sqrt(tte), math.exp(-r * tte))
            impliedBpVol = bachelierFormulaImpliedVol(OptionType.Call, strike, forward, tte, callPrem,
                                                      math.exp(-r * tte))
            self.assertAlmostEqual(impliedBpVol, bpvol, 12)

            callPrem = bachelierFormula(OptionType.Put, strike, forward, bpvol * math.sqrt(tte), math.exp(-r * tte))
            impliedBpVol = bachelierFormulaImpliedVol(OptionType.Put, strike, forward, tte, callPrem,
                                                      math.exp(-r * tte))
            self.assertAlmostEqual(impliedBpVol, bpvol, 12)