voly 0.0.235__py3-none-any.whl → 0.0.237__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/core/data.py +12 -6
- voly/formulas.py +1 -0
- {voly-0.0.235.dist-info → voly-0.0.237.dist-info}/METADATA +1 -1
- {voly-0.0.235.dist-info → voly-0.0.237.dist-info}/RECORD +7 -7
- {voly-0.0.235.dist-info → voly-0.0.237.dist-info}/WHEEL +0 -0
- {voly-0.0.235.dist-info → voly-0.0.237.dist-info}/licenses/LICENSE +0 -0
- {voly-0.0.235.dist-info → voly-0.0.237.dist-info}/top_level.txt +0 -0
voly/core/data.py
CHANGED
@@ -268,6 +268,12 @@ def process_option_chain(df: pd.DataFrame, currency: str) -> pd.DataFrame:
|
|
268
268
|
.replace(hour=8, minute=0, second=0, tzinfo=dt.timezone.utc)
|
269
269
|
.timestamp() * 1000)), unit='ms')
|
270
270
|
|
271
|
+
# Get reference time from timestamp
|
272
|
+
reference_time = dt.datetime.fromtimestamp(df['timestamp'].iloc[0] / 1000)
|
273
|
+
|
274
|
+
# Calculate time to expiry in years
|
275
|
+
df['t'] = ((df['expiry'] - reference_time).dt.total_seconds() / (24 * 60 * 60)) / 365.25
|
276
|
+
|
271
277
|
# Calculate implied volatility (convert from percentage)
|
272
278
|
df['mark_iv'] = df['mark_iv'] / 100
|
273
279
|
df['bid_iv'] = df['bid_iv'].replace({0: np.nan}) / 100
|
@@ -307,12 +313,12 @@ def process_option_chain(df: pd.DataFrame, currency: str) -> pd.DataFrame:
|
|
307
313
|
df['bid_depth'] = df['bids']
|
308
314
|
df['ask_depth'] = df['asks']
|
309
315
|
|
310
|
-
df['bs'] =
|
311
|
-
df['delta'] =
|
312
|
-
df['gamma'] =
|
313
|
-
df['vega'] =
|
314
|
-
df['theta'] =
|
315
|
-
df['rho'] =
|
316
|
+
df['bs'] = bs(df['spot_price'], df['strikes'], df['interest_rate'], df['mark_iv'], df['t'], df['flag'])
|
317
|
+
df['delta'] = delta(df['spot_price'], df['strikes'], df['interest_rate'], df['mark_iv'], df['t'], df['flag'])
|
318
|
+
df['gamma'] = gamma(df['spot_price'], df['strikes'], df['interest_rate'], df['mark_iv'], df['t'], df['flag']) * 10000
|
319
|
+
df['vega'] = vega(df['spot_price'], df['strikes'], df['interest_rate'], df['mark_iv'], df['t'], df['flag'])
|
320
|
+
df['theta'] = theta(df['spot_price'], df['strikes'], df['interest_rate'], df['mark_iv'], df['t'], df['flag'])
|
321
|
+
df['rho'] = rho(df['spot_price'], df['strikes'], df['interest_rate'], df['mark_iv'], df['t'], df['flag'])
|
316
322
|
|
317
323
|
df['open_interest'] = df['open_interest'] * s
|
318
324
|
df['volume'] = df['volume'] * s
|
voly/formulas.py
CHANGED
@@ -9,6 +9,7 @@ from py_vollib.black_scholes.implied_volatility import implied_volatility
|
|
9
9
|
from typing import Tuple, Dict, Union, List, Optional
|
10
10
|
from voly.utils.logger import catch_exception
|
11
11
|
from voly.exceptions import VolyError
|
12
|
+
from functools import wraps
|
12
13
|
|
13
14
|
|
14
15
|
@catch_exception
|
@@ -1,11 +1,11 @@
|
|
1
1
|
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
2
2
|
voly/client.py,sha256=H4BY5n1isHOqMYX-Koe8-WKBKE6zxbdDYopDF58BPBI,14533
|
3
3
|
voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
|
4
|
-
voly/formulas.py,sha256=
|
4
|
+
voly/formulas.py,sha256=CY4VChzEgfuc9aLkUFt3ipyot8wr_2z8K1G2Zsw4Ov8,10317
|
5
5
|
voly/models.py,sha256=CGJQr13Uie7iwtx2hjViN9lMXeRN_uOqzp4u8NPaTlA,9282
|
6
6
|
voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
|
7
7
|
voly/core/charts.py,sha256=6MSU0z01fPOVSssodxdnFqchzDfupSmXq_e71WwDmVQ,12635
|
8
|
-
voly/core/data.py,sha256=
|
8
|
+
voly/core/data.py,sha256=0_h39xWAltAQKRJsMwh4OPRpKjOpA-de-gAZHfUsqSY,13525
|
9
9
|
voly/core/fit.py,sha256=R3aDgCjvZ30PujoE9pgnGQXPQOTTMbk7_-RQ0ZMx5ig,13918
|
10
10
|
voly/core/hd.py,sha256=dSv197RmSWFWbRRdoBzMrD_poT7ZiJ8hdD_wKE-Li_M,13559
|
11
11
|
voly/core/interpolate.py,sha256=GAkrqaar7A0D6UMipXQUp4vSHRfb44TmCG5Xiv9elXg,5176
|
@@ -13,8 +13,8 @@ voly/core/rnd.py,sha256=wiZ5OIjPDf1Th5_sQ9CZG5JgAo3EL8f63T_Rj1_VP-0,13214
|
|
13
13
|
voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
|
14
14
|
voly/utils/density.py,sha256=ONpRli-IaJDgOZ2sb27HHFc9_tkkGSATKl94JODd86A,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.237.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
17
|
+
voly-0.0.237.dist-info/METADATA,sha256=hk6bnFEkeQ_NLT7h1VAok-d-KzkXLXlQWexpvuzDMnk,4115
|
18
|
+
voly-0.0.237.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
19
|
+
voly-0.0.237.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
20
|
+
voly-0.0.237.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|