# Path: py_vollib/black/greeks/analytical.py
# def delta(flag, F, K, t, r, sigma):
# def theta(flag, F, K, t, r, sigma):
# def gamma(flag, F, K, t, r, sigma):
# def vega(flag, F, K, t, r, sigma):
# def rho(flag, F, K, t, r, sigma):
#     D1 = d1(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
#     D2 = d2(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
# 
# Path: py_vollib/black/greeks/numerical.py
# def delta(flag, F, K, t, r, sigma):
# def theta(flag, F, K, t, r, sigma):
# def vega(flag, F, K, t, r, sigma):
# def rho(flag, F, K, t, r, sigma):
# def gamma(flag, F, K, t, r, sigma):
# def test():
# 
# Path: py_vollib/ref_python/black/greeks/analytical.py
# N = norm.cdf
#     D1 = d1(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
#     D2 = d2(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
# def delta(flag, F, K, t, r, sigma):
# def theta(flag, F, K, t, r, sigma):
# def gamma(flag, F, K, t, r, sigma):
# def vega(flag, F, K, t, r, sigma):
# def rho(flag, F, K, t, r, sigma):
# 
# Path: py_vollib/ref_python/black/greeks/numerical.py
# def delta(flag, F, K, t, r, sigma):
# def theta(flag, F, K, t, r, sigma):
# def vega(flag, F, K, t, r, sigma):
# def rho(flag, F, K, t, r, sigma):
# def gamma(flag, F, K, t, r, sigma):
# def test():
# 
# Path: tests/test_utils.py
# def almost_equal(a, b, epsilon=1.0e-7):
#     return abs(a - b) < epsilon


import unittest
from py_vollib.black.greeks import analytical as c_analytical
from py_vollib.black.greeks import numerical as c_numerical
from py_vollib.ref_python.black.greeks import analytical as py_analytical
from py_vollib.ref_python.black.greeks import numerical as py_numerical
from tests.test_utils import almost_equal
        K = 90
        sigma = .2
        r = .02
        t = .5

        flag = 'p'
        c_put = c_numerical.gamma(flag, F, K, t, r, sigma)
        py_put = py_numerical.gamma(flag, F, K, t, r, sigma)
        self.assertTrue(almost_equal(c_put, py_put))

        flag = 'c'
        c_call = c_numerical.gamma(flag, F, K, t, r, sigma)
        py_call = py_numerical.gamma(flag, F, K, t, r, sigma)
        self.assertTrue(almost_equal(c_call, py_call))

    def test_numerical_rho(self):
        F = 100
        K = 90
        sigma = .2
        r = .02
        t = .5

        flag = 'p'
        c_put = c_numerical.rho(flag, F, K, t, r, sigma)
        py_put = py_numerical.rho(flag, F, K, t, r, sigma)
        self.assertTrue(almost_equal(c_put, py_put))

        flag = 'c'
        c_call = c_numerical.rho(flag, F, K, t, r, sigma)
        py_call = py_numerical.rho(flag, F, K, t, r, sigma)

# Path: py_vollib/black/greeks/analytical.py
# def delta(flag, F, K, t, r, sigma):
# def theta(flag, F, K, t, r, sigma):
# def gamma(flag, F, K, t, r, sigma):
# def vega(flag, F, K, t, r, sigma):
# def rho(flag, F, K, t, r, sigma):
#     D1 = d1(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
#     D2 = d2(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
# 
# Path: py_vollib/black/greeks/numerical.py
# def delta(flag, F, K, t, r, sigma):
# def theta(flag, F, K, t, r, sigma):
# def vega(flag, F, K, t, r, sigma):
# def rho(flag, F, K, t, r, sigma):
# def gamma(flag, F, K, t, r, sigma):
# def test():
# 
# Path: py_vollib/ref_python/black/greeks/analytical.py
# N = norm.cdf
#     D1 = d1(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
#     D2 = d2(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
#     D1 = d1(F, K, t, r, sigma)
# def delta(flag, F, K, t, r, sigma):
# def theta(flag, F, K, t, r, sigma):
# def gamma(flag, F, K, t, r, sigma):
# def vega(flag, F, K, t, r, sigma):
# def rho(flag, F, K, t, r, sigma):
# 
# Path: py_vollib/ref_python/black/greeks/numerical.py
# def delta(flag, F, K, t, r, sigma):
# def theta(flag, F, K, t, r, sigma):
# def vega(flag, F, K, t, r, sigma):
# def rho(flag, F, K, t, r, sigma):
# def gamma(flag, F, K, t, r, sigma):
# def test():
# 
# Path: tests/test_utils.py
# def almost_equal(a, b, epsilon=1.0e-7):
#     return abs(a - b) < epsilon


# Path: tests/test_vollib_vs_ref_python_values/black/test_greeks.py
import unittest
from py_vollib.black.greeks import analytical as c_analytical
from py_vollib.black.greeks import numerical as c_numerical
from py_vollib.ref_python.black.greeks import analytical as py_analytical
from py_vollib.ref_python.black.greeks import numerical as py_numerical
from tests.test_utils import almost_equal

        K = 90
        sigma = .2
        r = .02
        t = .5

        flag = 'p'
        c_put = c_numerical.gamma(flag, F, K, t, r, sigma)
        py_put = py_numerical.gamma(flag, F, K, t, r, sigma)
        self.assertTrue(almost_equal(c_put, py_put))

        flag = 'c'
        c_call = c_numerical.gamma(flag, F, K, t, r, sigma)
        py_call = py_numerical.gamma(flag, F, K, t, r, sigma)
        self.assertTrue(almost_equal(c_call, py_call))

    def test_numerical_rho(self):
        F = 100
        K = 90
        sigma = .2
        r = .02
        t = .5

        flag = 'p'
        c_put = c_numerical.rho(flag, F, K, t, r, sigma)
        py_put = py_numerical.rho(flag, F, K, t, r, sigma)
        self.assertTrue(almost_equal(c_put, py_put))

        flag = 'c'
        c_call = c_numerical.rho(flag, F, K, t, r, sigma)
        py_call = py_numerical.rho(flag, F, K, t, r, sigma)

        self.assertTrue(almost_equal(c_call, py_call))