예제 #1
0
    def test_cox_ross_rubinstein_binomial(self):

        # Test if the output is a float
        self.assertIsInstance(
            Pricer().price(option_method='crr_bin'), float)
        self.assertIsInstance(Pricer().price(option_method='crr_bin',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500,
            output_flag='all', option='put', american=True,
            timing=True)['Price'], float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().price(option_method='crr_bin'), 0)
        self.assertGreater(Pricer().price(option_method='crr_bin',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500,
            output_flag='all', option='put', american=True,
            timing=True)['Price'], 0)

        # Print the output from running the function
        print("Default cox_ross_rubinstein_binomial: ",
              Pricer().price(option_method='crr_bin'))
        print("Revalued cox_ross_rubinstein_binomial: ",
              Pricer().price(option_method='crr_bin',
                  S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500,
                  output_flag='all', option='put', american=True,
                  timing=True)['Price'])
예제 #2
0
    def test_black_76(self):

        # Test if the output is a float
        self.assertIsInstance(Pricer().price(option_method='black76'), float)
        self.assertIsInstance(Pricer().price(option_method='black76',
            F=50, K=55, T=1, r=0.05, sigma=0.3, option='put',
            timing=True), float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().price(option_method='black76'), 0)
        self.assertGreater(Pricer().price(option_method='black76',
            F=50, K=55, T=1, r=0.05, sigma=0.3, option='put',
            timing=True), 0)

        # Print the output from running the function
        print("Default black_76: ", Pricer().price(option_method='black76'))
        print("Revalued black_76: ", Pricer().price(option_method='black76',
            F=50, K=55, T=1, r=0.05, sigma=0.3, option='put',
            timing=True))
예제 #3
0
    def test_hull_white_87(self):

        # Test if the output is a float
        self.assertIsInstance(Pricer().price(option_method='hw87'), float)
        self.assertIsInstance(Pricer().price(option_method='hw87',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, vvol=0.3,
            option='put', timing=True), float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().price(option_method='hw87'), 0)
        self.assertGreater(Pricer().price(option_method='hw87',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, vvol=0.3,
            option='put', timing=True), 0)

        # Print the output from running the function
        print("Default hull_white_87: ", Pricer().price(option_method='hw87'))
        print("Revalued hull_white_87: ", Pricer().price(option_method='hw87',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, vvol=0.3,
            option='put', timing=True))
예제 #4
0
    def test_crank_nicolson(self):

        # Test if the output is a float
        self.assertIsInstance(
            Pricer().price(option_method='cn'), float)
        self.assertIsInstance(Pricer().price(option_method='cn',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500, nodes=50,
            option='put', american=True, timing=True), float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().price(option_method='cn'), 0)
        self.assertGreater(Pricer().price(option_method='cn',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500, nodes=50,
            option='put', american=True, timing=True), 0)

        # Print the output from running the function
        print("Default crank_nicolson: ", Pricer().price(option_method='cn'))
        print("Revalued crank_nicolson: ", Pricer().price(option_method='cn',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500, nodes=50,
            option='put', american=True, timing=True))
예제 #5
0
    def test_european_binomial(self):

        # Test if the output is a float
        self.assertIsInstance(Pricer().price(option_method='euro_bin'), float)
        self.assertIsInstance(Pricer().price(option_method='euro_bin',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500,
            option='put', timing=True), float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().price(option_method='euro_bin'), 0)
        self.assertGreater(Pricer().price(option_method='euro_bin',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500,
            option='put', timing=True), 0)

        # Print the output from running the function
        print("Default european_binomial: ",
              Pricer().price(option_method='euro_bin'))
        print("Revalued european_binomial: ",
              Pricer().price(option_method='euro_bin',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500,
            option='put', timing=True))
예제 #6
0
    def test_implied_vol_naive(self):

        # Test if the output is a float
        self.assertIsInstance(Pricer().impliedvol(vol_method='naive'), float)
        self.assertIsInstance(Pricer().impliedvol(vol_method='naive',
            S=50, K=55, T=1, r=0.05, q=0.01, cm=7.57, epsilon=0.001,
            option='put', timing=True), float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().impliedvol(vol_method='naive'), 0)
        self.assertGreater(Pricer().impliedvol(vol_method='naive',
            S=50, K=55, T=1, r=0.05, q=0.01, cm=7.57, epsilon=0.001,
            option='put', timing=True), 0)

        # Print the output from running the function
        print("Default implied_vol_naive: ",
              Pricer().impliedvol(vol_method='naive'))
        print("Revalued implied_vol_naive: ",
              Pricer().impliedvol(vol_method='naive',
                  S=50, K=55, T=1, r=0.05, q=0.01, cm=7.57, epsilon=0.001,
                  option='put', timing=True))
예제 #7
0
    def test_implicit_finite_difference(self):

        # Test if the output is a float
        self.assertIsInstance(Pricer().price(option_method='ifd'), float)
        self.assertIsInstance(Pricer().price(option_method='ifd',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500, nodes=50,
            option='put', american=True, timing=True), float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().price(option_method='ifd'), 0)
        self.assertGreater(Pricer().price(option_method='ifd',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500, nodes=50,
            option='put', american=True, timing=True), 0)

        # Print the output from running the function
        print("Default implicit_finite_difference: ",
              Pricer().price(option_method='ifd'))
        print("Revalued implicit_finite_difference: ",
              Pricer().price(option_method='ifd',
                  S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps=500,
                  nodes=50, option='put', american=True, timing=True))
예제 #8
0
    def test_european_monte_carlo_with_greeks(self):

        # Test if the output is a float
        self.assertIsInstance(
            Pricer().price(option_method='emc_greeks'), float)
        self.assertIsInstance(Pricer().price(option_method='emc_greeks',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, simulations=1000,
            option='put', output_flag='all', timing=True)['Price'], float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().price(option_method='emc_greeks'), 0)
        self.assertGreater(Pricer().price(option_method='emc_greeks',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, simulations=1000,
            option='put', output_flag='all', timing=True)['Price'], 0)

        # Print the output from running the function
        print("Default european_monte_carlo_with_greeks: ",
              Pricer().price(option_method='emc_greeks'))
        print("Revalued european_monte_carlo_with_greeks: ",
              Pricer().price(option_method='emc_greeks',
                  S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, simulations=1000,
                  option='put', output_flag='all', timing=True)['Price'])
예제 #9
0
    def test_implied_trinomial_tree(self):

        # Test if the output is a float
        self.assertIsInstance(Pricer().price(option_method='itt'), float)
        self.assertIsInstance(Pricer().price(option_method='itt',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps_itt=5, step=4,
            state=4, skew=0.0005, output_flag='price', option='put',
            timing=True), float)

        # Test if the value of the output is greater than zero
        self.assertGreater(Pricer().price(option_method='itt'), 0)
        self.assertGreater(Pricer().price(option_method='itt',
            S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps_itt=5, step=4,
            state=4, skew=0.0005, output_flag='price', option='put',
            timing=True), 0)

        # Print the output from running the function
        print("Default implied_trinomial_tree: ",
              Pricer().price(option_method='itt'))
        print("Revalued implied_trinomial_tree: ",
              Pricer().price(option_method='itt',
                  S=50, K=55, T=1, r=0.05, q=0.01, sigma=0.3, steps_itt=5,
                  step=4, state=4, skew=0.0005, output_flag='price',
                  option='put', timing=True))