Skip to content

Commit d5fc40c

Browse files
committed
option lib
1 parent 8e545a6 commit d5fc40c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tigeropen/examples/option_helpers/helpers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# @Date : 2022/4/15
44
# @Author : sukai
55
import argparse
6-
import sys
76
from typing import List
87

9-
import QuantLib as ql
8+
try:
9+
import QuantLib as ql
10+
except ImportError:
11+
pass
1012

1113

1214
class FDDividendOptionHelper(ql.DividendVanillaOption):
@@ -112,7 +114,7 @@ def implied_volatility(self, price: float, accuracy: float = 1.0e-4, max_evaluat
112114
if try_times == 0:
113115
return 0
114116
elif 'root not bracketed' in str(e):
115-
return self.implied_volatility(price, accuracy, max_evaluations, min_vol, max_vol * 2, try_times-1)
117+
return self.implied_volatility(price, accuracy, max_evaluations, min_vol, max_vol * 2, try_times - 1)
116118
else:
117119
raise e
118120

0 commit comments

Comments
 (0)