comparison tests/test_helpers.py @ 1:b853194dc28b

add methods for eu call option
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Mon, 15 Nov 2021 23:14:41 +0100
parents
children ccffaf75d240
comparison
equal deleted inserted replaced
0:e5f3f855e6f9 1:b853194dc28b
1 from unittest import TestCase
2 from fbs.helpers import Option
3
4
5 class TestOption(TestCase):
6 option = Option(
7 spot_price=20.00,
8 exercise_price=21.00,
9 risk_free_rate=0.05,
10 std=0.25,
11 expiration=0.5 # 6 month (half year)
12 )
13
14 def test_compute_eu_call_price(self):
15 price = self.option.compute_eu_call_price()
16 price = round(price, 2)
17
18 self.assertEqual(price, 1.20, 'EU call price is not equal to 1.20')
19
20 def test_compute_d1(self):
21 d1 = self.option.compute_d1()
22 d1 = round(d1, 2)
23
24 self.assertEqual(d1, -0.05, 'D1 coefficient is not equal to -0.05')
25
26 def test_compute_d2(self):
27 d2 = self.option.compute_d2()
28 d2 = round(d2, 2)
29
30 self.assertEqual(d2, -0.22, 'D2 coefficient is now equal to -0.22')