voly 0.0.47__py3-none-any.whl → 0.0.50__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- voly/client.py +16 -12
- voly/formulas.py +20 -20
- {voly-0.0.47.dist-info → voly-0.0.50.dist-info}/METADATA +1 -1
- {voly-0.0.47.dist-info → voly-0.0.50.dist-info}/RECORD +7 -7
- {voly-0.0.47.dist-info → voly-0.0.50.dist-info}/LICENSE +0 -0
- {voly-0.0.47.dist-info → voly-0.0.50.dist-info}/WHEEL +0 -0
- {voly-0.0.47.dist-info → voly-0.0.50.dist-info}/top_level.txt +0 -0
voly/client.py
CHANGED
|
@@ -13,7 +13,7 @@ import plotly.graph_objects as go
|
|
|
13
13
|
|
|
14
14
|
from voly.utils.logger import logger, catch_exception, setup_file_logging
|
|
15
15
|
from voly.exceptions import VolyError
|
|
16
|
-
from voly.models import SVIModel
|
|
16
|
+
from voly.models import SVIModel
|
|
17
17
|
from voly.formulas import (
|
|
18
18
|
d1, d2, bs, delta, gamma, vega, theta, rho, vanna, volga, charm, greeks, iv
|
|
19
19
|
)
|
|
@@ -89,15 +89,15 @@ class VolyClient:
|
|
|
89
89
|
|
|
90
90
|
@staticmethod
|
|
91
91
|
def svi(log_moneyness_array: float, a: float, b: float, sigma: float, rho: float, m: float) -> float:
|
|
92
|
-
return svi(log_moneyness_array, a, b, sigma, rho, m)
|
|
92
|
+
return SVIModel.svi(log_moneyness_array, a, b, sigma, rho, m)
|
|
93
93
|
|
|
94
94
|
@staticmethod
|
|
95
95
|
def svi_d(log_moneyness_array: float, a: float, b: float, sigma: float, rho: float, m: float) -> float:
|
|
96
|
-
return svi_d(log_moneyness_array, a, b, sigma, rho, m)
|
|
96
|
+
return SVIModel.svi_d(log_moneyness_array, a, b, sigma, rho, m)
|
|
97
97
|
|
|
98
98
|
@staticmethod
|
|
99
99
|
def svi_dd(log_moneyness_array: float, a: float, b: float, sigma: float, rho: float, m: float) -> float:
|
|
100
|
-
return svi_dd(log_moneyness_array, a, b, sigma, rho, m)
|
|
100
|
+
return SVIModel.svi_dd(log_moneyness_array, a, b, sigma, rho, m)
|
|
101
101
|
|
|
102
102
|
@staticmethod
|
|
103
103
|
def d1(s: float, k: float, r: float, vol: float, t: float,
|
|
@@ -148,7 +148,8 @@ class VolyClient:
|
|
|
148
148
|
return delta(s, k, r, vol, t, option_type)
|
|
149
149
|
|
|
150
150
|
@staticmethod
|
|
151
|
-
def gamma(s: float, k: float, r: float, vol: float, t: float
|
|
151
|
+
def gamma(s: float, k: float, r: float, vol: float, t: float,
|
|
152
|
+
option_type: str = 'call') -> float:
|
|
152
153
|
"""
|
|
153
154
|
Calculate option gamma.
|
|
154
155
|
|
|
@@ -162,10 +163,11 @@ class VolyClient:
|
|
|
162
163
|
Returns:
|
|
163
164
|
- Gamma value
|
|
164
165
|
"""
|
|
165
|
-
return gamma(s, k, r, vol, t)
|
|
166
|
+
return gamma(s, k, r, vol, t, option_type)
|
|
166
167
|
|
|
167
168
|
@staticmethod
|
|
168
|
-
def vega(s: float, k: float, r: float, vol: float, t: float
|
|
169
|
+
def vega(s: float, k: float, r: float, vol: float, t: float,
|
|
170
|
+
option_type: str = 'call') -> float:
|
|
169
171
|
"""
|
|
170
172
|
Calculate option vega.
|
|
171
173
|
|
|
@@ -179,7 +181,7 @@ class VolyClient:
|
|
|
179
181
|
Returns:
|
|
180
182
|
- Vega value (for 1% change in volatility)
|
|
181
183
|
"""
|
|
182
|
-
return vega(s, k, r, vol, t)
|
|
184
|
+
return vega(s, k, r, vol, t, option_type)
|
|
183
185
|
|
|
184
186
|
@staticmethod
|
|
185
187
|
def theta(s: float, k: float, r: float, vol: float, t: float,
|
|
@@ -220,7 +222,8 @@ class VolyClient:
|
|
|
220
222
|
return rho(s, k, r, vol, t, option_type)
|
|
221
223
|
|
|
222
224
|
@staticmethod
|
|
223
|
-
def vanna(s: float, k: float, r: float, vol: float, t: float
|
|
225
|
+
def vanna(s: float, k: float, r: float, vol: float, t: float,
|
|
226
|
+
option_type: str = 'call') -> float:
|
|
224
227
|
"""
|
|
225
228
|
Calculate option vanna.
|
|
226
229
|
|
|
@@ -234,10 +237,11 @@ class VolyClient:
|
|
|
234
237
|
Returns:
|
|
235
238
|
- Vanna value
|
|
236
239
|
"""
|
|
237
|
-
return vanna(s, k, r, vol, t)
|
|
240
|
+
return vanna(s, k, r, vol, t, option_type)
|
|
238
241
|
|
|
239
242
|
@staticmethod
|
|
240
|
-
def volga(s: float, k: float, r: float, vol: float, t: float
|
|
243
|
+
def volga(s: float, k: float, r: float, vol: float, t: float,
|
|
244
|
+
option_type: str = 'call') -> float:
|
|
241
245
|
"""
|
|
242
246
|
Calculate option volga (vomma).
|
|
243
247
|
|
|
@@ -251,7 +255,7 @@ class VolyClient:
|
|
|
251
255
|
Returns:
|
|
252
256
|
- Volga value
|
|
253
257
|
"""
|
|
254
|
-
return volga(s, k, r, vol, t)
|
|
258
|
+
return volga(s, k, r, vol, t, option_type)
|
|
255
259
|
|
|
256
260
|
@staticmethod
|
|
257
261
|
def charm(s: float, k: float, r: float, vol: float, t: float,
|
voly/formulas.py
CHANGED
|
@@ -90,21 +90,21 @@ def delta(s: float, k: float, r: float, vol: float, t: float, option_type: str =
|
|
|
90
90
|
|
|
91
91
|
@catch_exception
|
|
92
92
|
@vectorize_inputs
|
|
93
|
-
def gamma(s: float, k: float, r: float, vol: float, t: float) -> float:
|
|
93
|
+
def gamma(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
|
|
94
94
|
if vol <= 0 or t <= 0:
|
|
95
95
|
return 0.0
|
|
96
96
|
|
|
97
|
-
d1_val = d1(s, k, r, vol, t)
|
|
97
|
+
d1_val = d1(s, k, r, vol, t, option_type)
|
|
98
98
|
return norm.pdf(d1_val) / (s * vol * np.sqrt(t))
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
@catch_exception
|
|
102
102
|
@vectorize_inputs
|
|
103
|
-
def vega(s: float, k: float, r: float, vol: float, t: float) -> float:
|
|
103
|
+
def vega(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
|
|
104
104
|
if vol <= 0 or t <= 0:
|
|
105
105
|
return 0.0
|
|
106
106
|
|
|
107
|
-
d1_val = d1(s, k, r, vol, t)
|
|
107
|
+
d1_val = d1(s, k, r, vol, t, option_type)
|
|
108
108
|
return s * norm.pdf(d1_val) * np.sqrt(t) / 100 # Divided by 100 for 1% change
|
|
109
109
|
|
|
110
110
|
|
|
@@ -114,8 +114,8 @@ def theta(s: float, k: float, r: float, vol: float, t: float, option_type: str =
|
|
|
114
114
|
if vol <= 0 or t <= 0:
|
|
115
115
|
return 0.0
|
|
116
116
|
|
|
117
|
-
d1_val = d1(s, k, r, vol, t)
|
|
118
|
-
d2_val = d2(s, k, r, vol, t)
|
|
117
|
+
d1_val = d1(s, k, r, vol, t, option_type)
|
|
118
|
+
d2_val = d2(s, k, r, vol, t, option_type)
|
|
119
119
|
|
|
120
120
|
# First part of theta (same for both call and put)
|
|
121
121
|
theta_part1 = -s * norm.pdf(d1_val) * vol / (2 * np.sqrt(t))
|
|
@@ -136,7 +136,7 @@ def rho(s: float, k: float, r: float, vol: float, t: float, option_type: str = '
|
|
|
136
136
|
if vol <= 0 or t <= 0:
|
|
137
137
|
return 0.0
|
|
138
138
|
|
|
139
|
-
d2_val = d2(s, k, r, vol, t)
|
|
139
|
+
d2_val = d2(s, k, r, vol, t, option_type)
|
|
140
140
|
|
|
141
141
|
if option_type.lower() in ["call", "c"]:
|
|
142
142
|
return k * t * np.exp(-r * t) * norm.cdf(d2_val) / 100
|
|
@@ -146,24 +146,24 @@ def rho(s: float, k: float, r: float, vol: float, t: float, option_type: str = '
|
|
|
146
146
|
|
|
147
147
|
@catch_exception
|
|
148
148
|
@vectorize_inputs
|
|
149
|
-
def vanna(s: float, k: float, r: float, vol: float, t: float) -> float:
|
|
149
|
+
def vanna(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
|
|
150
150
|
if vol <= 0 or t <= 0:
|
|
151
151
|
return 0.0
|
|
152
152
|
|
|
153
|
-
d1_val = d1(s, k, r, vol, t)
|
|
154
|
-
d2_val = d2(s, k, r, vol, t)
|
|
153
|
+
d1_val = d1(s, k, r, vol, t, option_type)
|
|
154
|
+
d2_val = d2(s, k, r, vol, t, option_type)
|
|
155
155
|
|
|
156
156
|
return -norm.pdf(d1_val) * d2_val / vol
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
@catch_exception
|
|
160
160
|
@vectorize_inputs
|
|
161
|
-
def volga(s: float, k: float, r: float, vol: float, t: float) -> float:
|
|
161
|
+
def volga(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
|
|
162
162
|
if vol <= 0 or t <= 0:
|
|
163
163
|
return 0.0
|
|
164
164
|
|
|
165
|
-
d1_val = d1(s, k, r, vol, t)
|
|
166
|
-
d2_val = d2(s, k, r, vol, t)
|
|
165
|
+
d1_val = d1(s, k, r, vol, t, option_type)
|
|
166
|
+
d2_val = d2(s, k, r, vol, t, option_type)
|
|
167
167
|
|
|
168
168
|
return s * norm.pdf(d1_val) * np.sqrt(t) * d1_val * d2_val / vol
|
|
169
169
|
|
|
@@ -174,8 +174,8 @@ def charm(s: float, k: float, r: float, vol: float, t: float, option_type: str =
|
|
|
174
174
|
if vol <= 0 or t <= 0:
|
|
175
175
|
return 0.0
|
|
176
176
|
|
|
177
|
-
d1_val = d1(s, k, r, vol, t)
|
|
178
|
-
d2_val = d2(s, k, r, vol, t)
|
|
177
|
+
d1_val = d1(s, k, r, vol, t, option_type)
|
|
178
|
+
d2_val = d2(s, k, r, vol, t, option_type)
|
|
179
179
|
|
|
180
180
|
# First term is the same for calls and puts
|
|
181
181
|
term1 = -norm.pdf(d1_val) * d1_val / (2 * t)
|
|
@@ -187,7 +187,7 @@ def charm(s: float, k: float, r: float, vol: float, t: float, option_type: str =
|
|
|
187
187
|
term2 = r * np.exp(-r * t) * norm.cdf(-d2_val)
|
|
188
188
|
|
|
189
189
|
# Return charm per day (t is in years)
|
|
190
|
-
return (term1 + term2) / 365.
|
|
190
|
+
return (term1 + term2) / 365.25
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
@catch_exception
|
|
@@ -197,12 +197,12 @@ def greeks(s: float, k: float, r: float, vol: float, t: float,
|
|
|
197
197
|
return {
|
|
198
198
|
'price': bs(s, k, r, vol, t, option_type),
|
|
199
199
|
'delta': delta(s, k, r, vol, t, option_type),
|
|
200
|
-
'gamma': gamma(s, k, r, vol, t),
|
|
201
|
-
'vega': vega(s, k, r, vol, t),
|
|
200
|
+
'gamma': gamma(s, k, r, vol, t, option_type),
|
|
201
|
+
'vega': vega(s, k, r, vol, t, option_type),
|
|
202
202
|
'theta': theta(s, k, r, vol, t, option_type),
|
|
203
203
|
'rho': rho(s, k, r, vol, t, option_type),
|
|
204
|
-
'vanna': vanna(s, k, r, vol, t),
|
|
205
|
-
'volga': volga(s, k, r, vol, t),
|
|
204
|
+
'vanna': vanna(s, k, r, vol, t, option_type),
|
|
205
|
+
'volga': volga(s, k, r, vol, t, option_type),
|
|
206
206
|
'charm': charm(s, k, r, vol, t, option_type)
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
|
2
|
-
voly/client.py,sha256=
|
|
2
|
+
voly/client.py,sha256=zOYgZA0TTJ5bHDCBWqEyeaQ0IKuee1uAIbzk0uyW_Uw,20350
|
|
3
3
|
voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
|
|
4
|
-
voly/formulas.py,sha256=
|
|
4
|
+
voly/formulas.py,sha256=Xgaq4lx1fNzRfu9W84fMNeH6GRJ0FNFNUUUYn5ffjjE,8843
|
|
5
5
|
voly/models.py,sha256=V2VI9yK-JyfKtI4nT5i42LQSwyGvexiymNiC2V1mQn4,3659
|
|
6
6
|
voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
|
|
7
7
|
voly/core/charts.py,sha256=T8cogkiHj8NcFxfARumNvAjLJUAxsMlHUOVgshwjye8,26474
|
|
@@ -11,8 +11,8 @@ voly/core/interpolate.py,sha256=ztVIePJZOh-CIbn69wkh1JW2rKywNe2FEewRN0zcSAo,8185
|
|
|
11
11
|
voly/core/rnd.py,sha256=8FTU-Qp9epW9yE4XSOdiFGIRXrGyXqF6mVgZn1NMvxk,11813
|
|
12
12
|
voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
|
|
13
13
|
voly/utils/logger.py,sha256=4-_2bVJmq17Q0d7Rd2mPg1AeR8gxv6EPvcmBDMFWcSM,1744
|
|
14
|
-
voly-0.0.
|
|
15
|
-
voly-0.0.
|
|
16
|
-
voly-0.0.
|
|
17
|
-
voly-0.0.
|
|
18
|
-
voly-0.0.
|
|
14
|
+
voly-0.0.50.dist-info/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
|
15
|
+
voly-0.0.50.dist-info/METADATA,sha256=sLeP_KK8Rc3bqPeG3GOQIQUrALDoaIPAZ_iwXUUuO7M,4092
|
|
16
|
+
voly-0.0.50.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
|
17
|
+
voly-0.0.50.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
|
18
|
+
voly-0.0.50.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|