@@ -63,14 +63,14 @@ def price_formula(strike, spot, sigma, texp, cp=1, intr=0.0, divr=0.0, is_fwd=Fa
63
63
Returns:
64
64
Vanilla option price
65
65
"""
66
+ df = np .exp (- texp * intr )
67
+ fwd = np .array (spot ) * (1.0 if is_fwd else np .exp (- texp * divr ) / df )
66
68
67
- disc_fac = np .exp (- texp * intr )
68
- fwd = spot * (1.0 if is_fwd else np .exp (- texp * divr ) / disc_fac )
69
-
70
- sigma_std = np .maximum (sigma * np .sqrt (texp ), np .finfo (float ).eps )
69
+ sigma_std = np .maximum (np .array (sigma ) * np .sqrt (texp ), np .finfo (float ).eps )
71
70
d = (fwd - strike ) / sigma_std
72
71
73
- price = disc_fac * (cp * (fwd - strike )* spst .norm .cdf (cp * d ) + sigma_std * spst .norm .pdf (d ))
72
+ cp = np .array (cp )
73
+ price = df * (cp * (fwd - strike )* spst .norm .cdf (cp * d ) + sigma_std * spst .norm .pdf (d ))
74
74
return price
75
75
76
76
def _impvol_Choi2009 (self , price , strike , spot , texp , cp = 1 , setval = False ):
@@ -94,8 +94,8 @@ def _impvol_Choi2009(self, price, strike, spot, texp, cp=1, setval=False):
94
94
implied volatility
95
95
"""
96
96
fwd , df , _ = self ._fwd_factor (spot , texp )
97
- price_fwd = price / df
98
- strike_std = cp * (fwd - strike )
97
+ price_fwd = np . array ( price ) / df
98
+ strike_std = np . array ( cp ) * (fwd - strike )
99
99
100
100
time_val = price_fwd - np .maximum (0 , strike_std ) # option time value
101
101
strd = 2 * price_fwd - strike_std # straddle value (=call + put)
0 commit comments