voly 0.0.162__py3-none-any.whl → 0.0.164__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/formulas.py +1 -28
- {voly-0.0.162.dist-info → voly-0.0.164.dist-info}/METADATA +1 -1
- {voly-0.0.162.dist-info → voly-0.0.164.dist-info}/RECORD +6 -6
- {voly-0.0.162.dist-info → voly-0.0.164.dist-info}/WHEEL +0 -0
- {voly-0.0.162.dist-info → voly-0.0.164.dist-info}/licenses/LICENSE +0 -0
- {voly-0.0.162.dist-info → voly-0.0.164.dist-info}/top_level.txt +0 -0
voly/formulas.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
Option pricing formulas and general calculations.
|
3
3
|
"""
|
4
4
|
|
5
|
+
import pandas as pd
|
5
6
|
import numpy as np
|
6
7
|
from scipy.stats import norm
|
7
8
|
from py_vollib.black_scholes.implied_volatility import implied_volatility
|
@@ -60,8 +61,6 @@ def vectorize_inputs(func):
|
|
60
61
|
@vectorize_inputs
|
61
62
|
def d1(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
62
63
|
# option_type is ignored in this function but included for compatibility
|
63
|
-
if o <= 0 or t <= 0:
|
64
|
-
return np.nan
|
65
64
|
return (np.log(s / K) + (r + o ** 2 / 2) * t) / (o * np.sqrt(t))
|
66
65
|
|
67
66
|
|
@@ -69,8 +68,6 @@ def d1(s: float, K: float, r: float, o: float, t: float, option_type: str = 'cal
|
|
69
68
|
@vectorize_inputs
|
70
69
|
def d2(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
71
70
|
# option_type is ignored in this function but included for compatibility
|
72
|
-
if o <= 0 or t <= 0:
|
73
|
-
return np.nan
|
74
71
|
return d1(s, K, r, o, t, option_type) - o * np.sqrt(t)
|
75
72
|
|
76
73
|
|
@@ -114,9 +111,6 @@ def delta(s: float, K: float, r: float, o: float, t: float, option_type: str = '
|
|
114
111
|
@catch_exception
|
115
112
|
@vectorize_inputs
|
116
113
|
def gamma(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
117
|
-
if o <= 0 or t <= 0:
|
118
|
-
return 0.0
|
119
|
-
|
120
114
|
d1_val = d1(s, K, r, o, t, option_type)
|
121
115
|
return norm.pdf(d1_val) / (s * o * np.sqrt(t))
|
122
116
|
|
@@ -124,9 +118,6 @@ def gamma(s: float, K: float, r: float, o: float, t: float, option_type: str = '
|
|
124
118
|
@catch_exception
|
125
119
|
@vectorize_inputs
|
126
120
|
def vega(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
127
|
-
if o <= 0 or t <= 0:
|
128
|
-
return 0.0
|
129
|
-
|
130
121
|
d1_val = d1(s, K, r, o, t, option_type)
|
131
122
|
return s * norm.pdf(d1_val) * np.sqrt(t) / 100 # Divided by 100 for 1% change
|
132
123
|
|
@@ -134,9 +125,6 @@ def vega(s: float, K: float, r: float, o: float, t: float, option_type: str = 'c
|
|
134
125
|
@catch_exception
|
135
126
|
@vectorize_inputs
|
136
127
|
def theta(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
137
|
-
if o <= 0 or t <= 0:
|
138
|
-
return 0.0
|
139
|
-
|
140
128
|
d1_val = d1(s, K, r, o, t, option_type)
|
141
129
|
d2_val = d2(s, K, r, o, t, option_type)
|
142
130
|
|
@@ -156,9 +144,6 @@ def theta(s: float, K: float, r: float, o: float, t: float, option_type: str = '
|
|
156
144
|
@catch_exception
|
157
145
|
@vectorize_inputs
|
158
146
|
def rho(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
159
|
-
if o <= 0 or t <= 0:
|
160
|
-
return 0.0
|
161
|
-
|
162
147
|
d2_val = d2(s, K, r, o, t, option_type)
|
163
148
|
|
164
149
|
if option_type.lower() in ["call", "c"]:
|
@@ -170,9 +155,6 @@ def rho(s: float, K: float, r: float, o: float, t: float, option_type: str = 'ca
|
|
170
155
|
@catch_exception
|
171
156
|
@vectorize_inputs
|
172
157
|
def vanna(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
173
|
-
if o <= 0 or t <= 0:
|
174
|
-
return 0.0
|
175
|
-
|
176
158
|
d1_val = d1(s, K, r, o, t, option_type)
|
177
159
|
d2_val = d2(s, K, r, o, t, option_type)
|
178
160
|
|
@@ -182,9 +164,6 @@ def vanna(s: float, K: float, r: float, o: float, t: float, option_type: str = '
|
|
182
164
|
@catch_exception
|
183
165
|
@vectorize_inputs
|
184
166
|
def volga(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
185
|
-
if o <= 0 or t <= 0:
|
186
|
-
return 0.0
|
187
|
-
|
188
167
|
d1_val = d1(s, K, r, o, t, option_type)
|
189
168
|
d2_val = d2(s, K, r, o, t, option_type)
|
190
169
|
|
@@ -194,9 +173,6 @@ def volga(s: float, K: float, r: float, o: float, t: float, option_type: str = '
|
|
194
173
|
@catch_exception
|
195
174
|
@vectorize_inputs
|
196
175
|
def charm(s: float, K: float, r: float, o: float, t: float, option_type: str = 'call') -> float:
|
197
|
-
if o <= 0 or t <= 0:
|
198
|
-
return 0.0
|
199
|
-
|
200
176
|
d1_val = d1(s, K, r, o, t, option_type)
|
201
177
|
d2_val = d2(s, K, r, o, t, option_type)
|
202
178
|
|
@@ -248,9 +224,6 @@ def iv(option_price: float, s: float, K: float, r: float, t: float,
|
|
248
224
|
Returns:
|
249
225
|
- Implied volatility
|
250
226
|
"""
|
251
|
-
if t <= 0:
|
252
|
-
return np.nan
|
253
|
-
|
254
227
|
# Check if option price is within theoretical bounds
|
255
228
|
if option_type.lower() in ["call", "c"]:
|
256
229
|
intrinsic = max(0, s - K * np.exp(-r * t))
|
@@ -1,7 +1,7 @@
|
|
1
1
|
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
2
2
|
voly/client.py,sha256=-yE1_cBvjkK-BO_kKCYtn4WPbNOhAzT0hsfykU5LvQQ,14761
|
3
3
|
voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
|
4
|
-
voly/formulas.py,sha256=
|
4
|
+
voly/formulas.py,sha256=cjNeYRG3_APYOTsOXSxYZj4ONlRpoS5cmMnfAkF0av0,11208
|
5
5
|
voly/models.py,sha256=o-pHujGfr5Gn8ItckMzLI4Q8yaX9FQaV8UjCxv2zgTY,3364
|
6
6
|
voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
|
7
7
|
voly/core/charts.py,sha256=E21OZB5lTY4YL2flgaFJ6s5g3_ExtAQT2zryZZxLPyM,12735
|
@@ -13,8 +13,8 @@ voly/core/rnd.py,sha256=GoC3m1Q46Wnk5tV_mstr-3_aktHeue6BBLh4DQTciW0,13307
|
|
13
13
|
voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
|
14
14
|
voly/utils/density.py,sha256=q0fX4im9TGwMCZ32Hzdv8CNh56KnJo8bmG5w0gVWZH8,5879
|
15
15
|
voly/utils/logger.py,sha256=4-_2bVJmq17Q0d7Rd2mPg1AeR8gxv6EPvcmBDMFWcSM,1744
|
16
|
-
voly-0.0.
|
17
|
-
voly-0.0.
|
18
|
-
voly-0.0.
|
19
|
-
voly-0.0.
|
20
|
-
voly-0.0.
|
16
|
+
voly-0.0.164.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
17
|
+
voly-0.0.164.dist-info/METADATA,sha256=nId1eDVu1a3ROTy8dy8w6hdIk5sN7EYQL6FTeB5TcxE,4115
|
18
|
+
voly-0.0.164.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
19
|
+
voly-0.0.164.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
20
|
+
voly-0.0.164.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|