voly 0.0.74__py3-none-any.whl → 0.0.75__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 +3 -7
- voly/core/charts.py +15 -15
- voly/core/data.py +3 -1
- voly/core/fit.py +1 -1
- {voly-0.0.74.dist-info → voly-0.0.75.dist-info}/METADATA +1 -1
- {voly-0.0.74.dist-info → voly-0.0.75.dist-info}/RECORD +9 -9
- {voly-0.0.74.dist-info → voly-0.0.75.dist-info}/LICENSE +0 -0
- {voly-0.0.74.dist-info → voly-0.0.75.dist-info}/WHEEL +0 -0
- {voly-0.0.74.dist-info → voly-0.0.75.dist-info}/top_level.txt +0 -0
voly/client.py
CHANGED
|
@@ -364,13 +364,13 @@ class VolyClient:
|
|
|
364
364
|
- Surface. Dict composed of (iv_surface, x_surface)
|
|
365
365
|
"""
|
|
366
366
|
# Generate the surface
|
|
367
|
-
|
|
367
|
+
iv_surface, x_surface = get_iv_surface(
|
|
368
368
|
fit_results=fit_results,
|
|
369
369
|
log_moneyness_params=log_moneyness_params,
|
|
370
370
|
return_domain=return_domain
|
|
371
371
|
)
|
|
372
372
|
|
|
373
|
-
return
|
|
373
|
+
return iv_surface, x_surface
|
|
374
374
|
|
|
375
375
|
@staticmethod
|
|
376
376
|
def plot_model(fit_results: pd.DataFrame,
|
|
@@ -393,11 +393,7 @@ class VolyClient:
|
|
|
393
393
|
plots = {}
|
|
394
394
|
|
|
395
395
|
# Generate IV surface and domain
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
# Get iv_surface and x_surface from the return value
|
|
399
|
-
iv_surface = surface['iv_surface']
|
|
400
|
-
x_surface = surface['x_surface']
|
|
396
|
+
iv_surface, x_surface = get_iv_surface(fit_results, log_moneyness_params, return_domain)
|
|
401
397
|
|
|
402
398
|
# Plot volatility smiles
|
|
403
399
|
plots['smiles'] = plot_all_smiles(
|
voly/core/charts.py
CHANGED
|
@@ -19,20 +19,20 @@ pio.renderers.default = "browser"
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
@catch_exception
|
|
22
|
-
def plot_volatility_smile(
|
|
22
|
+
def plot_volatility_smile(x_array: np.ndarray,
|
|
23
23
|
iv_array: np.ndarray,
|
|
24
24
|
option_chain: pd.DataFrame = None,
|
|
25
25
|
maturity: Optional[str] = None,
|
|
26
|
-
|
|
26
|
+
return_domain: str = 'log_moneyness') -> go.Figure:
|
|
27
27
|
"""
|
|
28
28
|
Plot volatility smile for a single expiry.
|
|
29
29
|
|
|
30
30
|
Parameters:
|
|
31
|
-
-
|
|
31
|
+
- x_array: Array of x-axis values in the specified domain
|
|
32
32
|
- iv_array: Implied volatility values
|
|
33
33
|
- option_chain: Optional market data for comparison
|
|
34
34
|
- maturity: Maturity name for filtering market data
|
|
35
|
-
-
|
|
35
|
+
- return_domain: Type of x-domain ('log_moneyness', 'moneyness', 'strikes', 'delta')
|
|
36
36
|
|
|
37
37
|
Returns:
|
|
38
38
|
- Plotly figure
|
|
@@ -40,9 +40,9 @@ def plot_volatility_smile(x_domain: np.ndarray,
|
|
|
40
40
|
# Map domain types to axis labels
|
|
41
41
|
domain_labels = {
|
|
42
42
|
'log_moneyness': 'Log Moneyness',
|
|
43
|
-
'moneyness': 'Moneyness
|
|
43
|
+
'moneyness': 'Moneyness',
|
|
44
44
|
'strikes': 'Strike Price',
|
|
45
|
-
'delta': '
|
|
45
|
+
'delta': 'Delta'
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
fig = go.Figure()
|
|
@@ -50,7 +50,7 @@ def plot_volatility_smile(x_domain: np.ndarray,
|
|
|
50
50
|
# Add model curve
|
|
51
51
|
fig.add_trace(
|
|
52
52
|
go.Scatter(
|
|
53
|
-
x=
|
|
53
|
+
x=x_array,
|
|
54
54
|
y=iv_array * 100, # Convert to percentage
|
|
55
55
|
mode='lines',
|
|
56
56
|
name='Model',
|
|
@@ -68,7 +68,7 @@ def plot_volatility_smile(x_domain: np.ndarray,
|
|
|
68
68
|
if iv_type in maturity_data.columns:
|
|
69
69
|
fig.add_trace(
|
|
70
70
|
go.Scatter(
|
|
71
|
-
x=maturity_data[
|
|
71
|
+
x=maturity_data[return_domain],
|
|
72
72
|
y=maturity_data[iv_type] * 100, # Convert to percentage
|
|
73
73
|
mode='markers',
|
|
74
74
|
name=iv_type.replace('_', ' ').upper(),
|
|
@@ -76,7 +76,7 @@ def plot_volatility_smile(x_domain: np.ndarray,
|
|
|
76
76
|
)
|
|
77
77
|
)
|
|
78
78
|
|
|
79
|
-
title = f'Vol Smile for {maturity} (
|
|
79
|
+
title = f'Vol Smile for {maturity} (DTM: {maturity_data["dtm"].iloc[0]:.1f})'
|
|
80
80
|
else:
|
|
81
81
|
title = f'Vol Smile for {maturity}'
|
|
82
82
|
else:
|
|
@@ -85,7 +85,7 @@ def plot_volatility_smile(x_domain: np.ndarray,
|
|
|
85
85
|
# Update layout
|
|
86
86
|
fig.update_layout(
|
|
87
87
|
title=title,
|
|
88
|
-
xaxis_title=domain_labels.get(
|
|
88
|
+
xaxis_title=domain_labels.get(return_domain, 'X Domain'),
|
|
89
89
|
yaxis_title='Implied Volatility (%)',
|
|
90
90
|
template='plotly_dark',
|
|
91
91
|
legend=dict(orientation='h', yanchor='bottom', y=1.02, xanchor='right', x=1)
|
|
@@ -98,7 +98,7 @@ def plot_volatility_smile(x_domain: np.ndarray,
|
|
|
98
98
|
def plot_all_smiles(x_surface: Dict[str, np.ndarray],
|
|
99
99
|
iv_surface: Dict[str, np.ndarray],
|
|
100
100
|
option_chain: Optional[pd.DataFrame] = None,
|
|
101
|
-
|
|
101
|
+
return_domain: str = 'log_moneyness') -> List[go.Figure]:
|
|
102
102
|
"""
|
|
103
103
|
Plot volatility smiles for all expiries.
|
|
104
104
|
|
|
@@ -106,18 +106,18 @@ def plot_all_smiles(x_surface: Dict[str, np.ndarray],
|
|
|
106
106
|
- x_surface: Dictionary mapping maturity names to x-domain arrays
|
|
107
107
|
- iv_surface: Dictionary mapping maturity names to IV arrays
|
|
108
108
|
- option_chain: Optional market data for comparison
|
|
109
|
-
-
|
|
109
|
+
- return_domain: Type of x-domain ('log_moneyness', 'moneyness', 'strikes', 'delta')
|
|
110
110
|
|
|
111
111
|
Returns:
|
|
112
112
|
- List of Plotly figures
|
|
113
113
|
"""
|
|
114
114
|
return [
|
|
115
115
|
plot_volatility_smile(
|
|
116
|
-
|
|
116
|
+
x_array=x_surface[maturity],
|
|
117
117
|
iv_array=iv_surface[maturity],
|
|
118
118
|
option_chain=option_chain,
|
|
119
119
|
maturity=maturity,
|
|
120
|
-
|
|
120
|
+
return_domain=return_domain
|
|
121
121
|
)
|
|
122
122
|
for maturity in iv_surface.keys()
|
|
123
123
|
]
|
|
@@ -148,7 +148,7 @@ def plot_raw_parameters(fit_results: pd.DataFrame) -> go.Figure:
|
|
|
148
148
|
maturity_names = fit_results.index
|
|
149
149
|
|
|
150
150
|
# Create hover text with maturity info
|
|
151
|
-
tick_labels = [f"{m} (
|
|
151
|
+
tick_labels = [f"{m} (DTM: {fit_results.loc[m, 'dtm']:.1f}"
|
|
152
152
|
for m in maturity_names]
|
|
153
153
|
|
|
154
154
|
# Plot each parameter
|
voly/core/data.py
CHANGED
|
@@ -224,7 +224,9 @@ def process_option_chain(df: pd.DataFrame, currency: str) -> pd.DataFrame:
|
|
|
224
224
|
df['ask_iv'] = df['ask_iv'].replace({0: np.nan}) / 100
|
|
225
225
|
|
|
226
226
|
# Calculate log-moneyness
|
|
227
|
-
df['log_moneyness'] = np.log(df['
|
|
227
|
+
df['log_moneyness'] = np.log(df['index_price'] / df['strike'])
|
|
228
|
+
# Calculate moneyness
|
|
229
|
+
df['moneyness'] = np.exp(df['log_moneyness'])
|
|
228
230
|
|
|
229
231
|
logger.info(f"Processing complete!")
|
|
230
232
|
|
voly/core/fit.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
|
2
|
-
voly/client.py,sha256=
|
|
2
|
+
voly/client.py,sha256=XPq1oPowyWdlpHRkr3WUN22LcoRBpPYvW0CpxoNUuKE,20741
|
|
3
3
|
voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
|
|
4
4
|
voly/formulas.py,sha256=wSbGAH6GuQThT9QyQY4Ud2eUf9fo1YFHglUmP6fNris,11871
|
|
5
5
|
voly/models.py,sha256=LXXIlpXZQEfXTuCngxC8Hd3bWtw6wdXDCSGxTLmHM-c,3659
|
|
6
6
|
voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
|
|
7
|
-
voly/core/charts.py,sha256=
|
|
8
|
-
voly/core/data.py,sha256=
|
|
9
|
-
voly/core/fit.py,sha256=
|
|
7
|
+
voly/core/charts.py,sha256=ZE_D9mVvO0TrUUnCWyPD3PXhpvXPyN8nHU4YJvc3ok4,27061
|
|
8
|
+
voly/core/data.py,sha256=iMF1eUq_pysyc4meRZyYHhXFiBQYfYlvenhyh6E_Erk,8933
|
|
9
|
+
voly/core/fit.py,sha256=JOr2XjM-I9HtfbyEN0tdGuNCZimQ2ttm4lNUpF-tKb4,9226
|
|
10
10
|
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.75.dist-info/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
|
15
|
+
voly-0.0.75.dist-info/METADATA,sha256=Gik0C5clXd_Lb2i329YByD9cBKia1IkwuAGHNyhacME,4092
|
|
16
|
+
voly-0.0.75.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
|
17
|
+
voly-0.0.75.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
|
18
|
+
voly-0.0.75.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|