diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_helpers.py	Mon Nov 15 23:14:41 2021 +0100
@@ -0,0 +1,30 @@
+from unittest import TestCase
+from fbs.helpers import Option
+
+
+class TestOption(TestCase):
+    option = Option(
+        spot_price=20.00,
+        exercise_price=21.00,
+        risk_free_rate=0.05,
+        std=0.25,
+        expiration=0.5  # 6 month (half year)
+    )
+
+    def test_compute_eu_call_price(self):
+        price = self.option.compute_eu_call_price()
+        price = round(price, 2)
+
+        self.assertEqual(price, 1.20, 'EU call price is not equal to 1.20')
+
+    def test_compute_d1(self):
+        d1 = self.option.compute_d1()
+        d1 = round(d1, 2)
+
+        self.assertEqual(d1, -0.05, 'D1 coefficient is not equal to -0.05')
+
+    def test_compute_d2(self):
+        d2 = self.option.compute_d2()
+        d2 = round(d2, 2)
+
+        self.assertEqual(d2, -0.22, 'D2 coefficient is now equal to -0.22')