Beispiel #1
0
    def test_ex6_put(self):
        self.params['q'] = 10.
        self.option_property['type'] = 'put'
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price = utils.call(self.method, self.params)

        self.assertAlmostEqual(72.38760561669933, price, places=15)
Beispiel #2
0
    def test_call_price_case2(self):
        self.params['spot'] = 95.
        self.option_property['direction'] = 'down_and_out'
        self.params['instrument'] = instruments.knock_out_continuous(
            self.option_property)
        black_out_price = utils.call('qlOptionCalcBlack', self.params)
        pde_out_price = utils.call('qlOptionCalcPDE', self.params)

        self.option_property['direction'] = 'down_and_in'
        self.params['instrument'] = instruments.knock_in_continuous(
            self.option_property)
        black_in_price = utils.call('qlOptionCalcBlack', self.params)
        pde_in_price = utils.call('qlOptionCalcPDE', self.params)

        self.params['instrument'] = instruments.vanilla_european(
            self.option_property)
        black_euro_price = utils.call('qlOptionCalcBlack', self.params)
        pde_euro_price = utils.call('qlOptionCalcPDE', self.params)

        rebate = self.option_property['rebate_amount']
        r = self.params['r']

        eps = self.params['spot'] * 1e-5
        self.assertAlmostEqual(pde_euro_price - pde_out_price +
                               rebate * exp(-r * 0.9993),
                               pde_in_price,
                               delta=eps)
Beispiel #3
0
    def test_ex5_put(self):
        self.params['q'] = -10.
        self.option_property['type'] = 'put'
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price = utils.call(self.method, self.params)

        self.assertAlmostEqual(18.097986565965865, price, places=15)
Beispiel #4
0
    def test_ex4_put(self):
        self.params['r'] = 10.
        self.option_property['type'] = 'put'
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price = utils.call(self.method, self.params)

        self.assertAlmostEqual(0.0009142347953555541, price, places=15)
Beispiel #5
0
    def test_barrier_lower_limit_case1(self):
        self.option_property['barrier'] = 0.0
        self.option_property['rebate_amount'] = 0.0
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        knock_in_price = utils.call(self.method, self.params)

        self.assertAlmostEqual(knock_in_price, 0.0, places=9)
Beispiel #6
0
 def test_call_price_case4(self):
     self.params['spot'] = 160.
     self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
     pde_price = utils.call(self.method, self.params)
     black_price = utils.call('qlOptionCalcBlack', self.params)
     eps = self.params['spot'] * 1e-5
     self.assertAlmostEqual(pde_price, black_price, delta=eps)
Beispiel #7
0
    def test_ex3_put(self):
        self.params['r'] = -10.
        self.option_property['type'] = 'put'
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price = utils.call(self.method, self.params)

        self.assertAlmostEqual(1750002.4108721288, price, places=15)
Beispiel #8
0
    def test_ex2_call(self):
        self.params['valDate'] = '2017-08-08T00:00:00'
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price1 = utils.call(self.method, self.params)
        price2 = self.option_property['rebate_amount']

        self.assertAlmostEqual(price1, price2, places=15)
Beispiel #9
0
    def test_call_price_case1(self):
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        self.params['spot'] = 90.
        price = utils.call(self.method, self.params)

        self.params['instrument'] = instruments.vanilla_european(self.option_property)
        vanilla_price = utils.call(self.method, self.params)
        self.assertAlmostEqual(vanilla_price, price, places=9)
Beispiel #10
0
    def test_ex9_call(self):
        self.params['vol'] = 1e-6
        self.params['r'] = 0
        self.params['q'] = 0
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price = utils.call(self.method, self.params)

        self.assertAlmostEqual(20, price, places=15)
Beispiel #11
0
    def test_ex7_call(self):
        self.params['vol'] = 1e-6
        self.params['r'] = 10.
        self.params['q'] = 0.
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price = utils.call(self.method, self.params)

        self.assertAlmostEqual(0.0009142348249076429, price, places=15)
Beispiel #12
0
    def test_ex1_put(self):
        self.params['vol'] = 0
        self.option_property['type'] = 'put'
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price1 = utils.call(self.method, self.params)
        self.params['vol'] = 1e-6
        price2 = utils.call(self.method, self.params)

        self.assertAlmostEqual(price1, price2, places=15)
Beispiel #13
0
    def test_barrier_upper_limit_case2(self):
        self.option_property['barrier'] = 1000.
        self.option_property['direction'] = 'up_and_in'
        self.option_property['rebate_amount'] = 0.0
        self.option_property['type'] = 'put'
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        knock_in_price = utils.call(self.method, self.params)

        self.assertAlmostEqual(knock_in_price, 0.0, places=9)
Beispiel #14
0
    def test_ex1_call(self):
        # self.option_property['barrier'] = 90.
        self.params['r'] = -0.1
        self.params['vol'] = 0
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price1 = utils.call(self.method, self.params)
        self.params['vol'] = 1e-6
        price2 = utils.call(self.method, self.params)

        self.assertAlmostEqual(price1, price2, places=15)
Beispiel #15
0
    def test_in_out_parity(self):
        self.option_property['rebate_amount'] = 0.
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        in_price = utils.call(self.method, self.params)

        self.option_property['direction'] = 'down_and_out'
        self.params['instrument'] = instruments.knock_out_continuous(self.option_property)
        out_price = utils.call(self.method, self.params)

        self.params['instrument'] = instruments.vanilla_european(self.option_property)
        vanilla_price = utils.call(self.method, self.params)
        self.assertAlmostEqual(out_price+in_price-vanilla_price, 0.0, places=9)
Beispiel #16
0
    def test_parity(self):
        self.option_property['rebate_amount'] = 0
        self.params['instrument'] = instruments.knock_out_continuous(
            self.option_property)
        knock_out_price = utils.call(self.method, self.params)

        self.option_property['direction'] = 'down_and_in'
        self.params['instrument'] = instruments.knock_in_continuous(
            self.option_property)
        knock_in_price = utils.call(self.method, self.params)

        self.params['instrument'] = instruments.vanilla_european(
            self.option_property)
        vanilla_price = utils.call(self.method, self.params)
        self.assertAlmostEqual(knock_out_price + knock_in_price,
                               vanilla_price,
                               delta=0)
Beispiel #17
0
    def test_ex4_call(self):
        self.params['r'] = 10.
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price = utils.call(self.method, self.params)

        self.assertAlmostEqual(0.0009169907572615757, price, places=15)
Beispiel #18
0
    def test_ex5_call(self):
        self.params['q'] = -10.
        self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
        price = utils.call(self.method, self.params)

        self.assertAlmostEqual(18.148698212347103, price, places=15)
Beispiel #19
0
 def test_put_price_case2(self):
     self.option_property['type'] = 'put'
     self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
     self.params['spot'] = 95.
     price = utils.call(self.method, self.params)
     self.assertAlmostEqual(5.499066511352499, price, places=9)
Beispiel #20
0
 def test_call_price_case2(self):
     self.params['instrument'] = instruments.knock_in_continuous(self.option_property)
     self.params['spot'] = 95.
     price = utils.call(self.method, self.params)
     self.assertAlmostEqual(18.10672675741688, price, places=9)