def test_ex7_put(self): self.params['q'] = 10. self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(4.994692417102769, price, places=15)
def test_call_price_case3(self): self.params['spot'] = 110. self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) tree_price = utils.call(self.method, self.params) rebate = self.option_property['upper_rebate'] self.assertAlmostEqual(tree_price, rebate, places=15)
def test_put_price_case2(self): self.params['spot'] = 100. self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(price, 7.273463970405533, places=9)
def test_ex6_put(self): self.params['q'] = -10. self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(9.990549279751074, price, places=15)
def test_ex2_put(self): self.params['vol'] = 1e-3 self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(0.036087902879740126, price, places=15)
def test_ex5_put(self): self.params['r'] = 10. self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(9.082179025578567, price, places=15)
def test_ex4_put(self): self.params['r'] = -10.0 self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(5.549751796764291, price, places=15)
def test_ex3_put(self): self.params['vol'] = 10. self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(7.499925463157357, price, places=15)
def test_ex13_call(self): self.params['vol'] = 10 self.params['r'] = 10 self.params['q'] = 10 self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(7.492552470854562, price, places=15)
def test_ex12_call(self): self.params['vol'] = 10 self.params['r'] = 10. self.params['q'] = 0. self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(7.517572769502204, price, places=15)
def test_call_price_case2(self): self.params['spot'] = 100. self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) tree_price = utils.call(self.method, self.params) black_price = utils.call('qlOptionCalcBlack', self.params) eps = self.params['spot'] * 1e-3 self.assertAlmostEqual(tree_price, black_price, delta=eps)
def test_ex11_call(self): self.params['vol'] = 10 self.params['r'] = -10. self.params['q'] = 0. self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(7.482397755413479, price, places=15)
def test_call_price_case1(self): self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) self.params['spot'] = 90. price = utils.call(self.method, self.params) self.assertAlmostEqual(price, self.option_property['lower_rebate'], places=9)
def test_put_price_case3(self): self.params['spot'] = 110. self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(price, self.option_property['upper_rebate'], places=9)
def test_ex10_put(self): self.params['vol'] = 1e-6 self.params['r'] = -10. self.params['q'] = 0. self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(5.555555555555555, price, places=15)
def test_ex1_call(self): self.params['vol'] = 0.0 # self.option_property['upper_rebate'] = 0 # self.option_property['lower_rebate'] = 0 # self.params['valDate'] = '2017-08-07T00:00:00' # self.params['r'] = 0.1 # self.option_property['rebate_type'] = 'pay_at_expiry' # self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(0.0, price, places=15)
def test_lower_limit_case3(self): self.option_property['lower_barrier'] = 0.1 self.option_property['type'] = 'put' self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) double_knock_out_price = utils.call(self.method, self.params) self.option_property['barrier'] = self.option_property['upper_barrier'] self.option_property['rebate_amount'] = self.option_property[ 'upper_rebate'] self.option_property['direction'] = 'up_and_out' self.params['instrument'] = instruments.knock_out_continuous( self.option_property) knock_out_price = utils.call(self.method, self.params) self.assertAlmostEqual(double_knock_out_price, knock_out_price, places=9)
def test_ex2_call(self): self.params['vol'] = 1e-4 self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) price = utils.call(self.method, self.params) self.assertAlmostEqual(0.003608790436758738, price, places=15)
def test_call_price_case2(self): self.params['instrument'] = instruments.double_knock_out_continuous( self.option_property) self.params['spot'] = 100. price = utils.call(self.method, self.params) self.assertAlmostEqual(7.269179953568781, price, places=9)