voly 0.0.67__tar.gz → 0.0.68__tar.gz
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-0.0.67/src/voly.egg-info → voly-0.0.68}/PKG-INFO +1 -1
- {voly-0.0.67 → voly-0.0.68}/pyproject.toml +2 -2
- {voly-0.0.67 → voly-0.0.68}/src/voly/core/fit.py +69 -20
- {voly-0.0.67 → voly-0.0.68/src/voly.egg-info}/PKG-INFO +1 -1
- {voly-0.0.67 → voly-0.0.68}/LICENSE +0 -0
- {voly-0.0.67 → voly-0.0.68}/README.md +0 -0
- {voly-0.0.67 → voly-0.0.68}/setup.cfg +0 -0
- {voly-0.0.67 → voly-0.0.68}/setup.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/__init__.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/client.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/core/__init__.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/core/charts.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/core/data.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/core/interpolate.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/core/rnd.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/exceptions.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/formulas.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/models.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/utils/__init__.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly/utils/logger.py +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly.egg-info/SOURCES.txt +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly.egg-info/dependency_links.txt +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly.egg-info/requires.txt +0 -0
- {voly-0.0.67 → voly-0.0.68}/src/voly.egg-info/top_level.txt +0 -0
- {voly-0.0.67 → voly-0.0.68}/tests/test_client.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "voly"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.68"
|
|
8
8
|
description = "Options & volatility research package"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -60,7 +60,7 @@ line_length = 100
|
|
|
60
60
|
multi_line_output = 3
|
|
61
61
|
|
|
62
62
|
[tool.mypy]
|
|
63
|
-
python_version = "0.0.
|
|
63
|
+
python_version = "0.0.68"
|
|
64
64
|
warn_return_any = true
|
|
65
65
|
warn_unused_configs = true
|
|
66
66
|
disallow_untyped_defs = true
|
|
@@ -53,22 +53,42 @@ def fit_model(option_chain: pd.DataFrame,
|
|
|
53
53
|
initial_params = initial_params or SVIModel.DEFAULT_INITIAL_PARAMS
|
|
54
54
|
param_bounds = param_bounds or SVIModel.DEFAULT_PARAM_BOUNDS
|
|
55
55
|
|
|
56
|
-
# Define column names
|
|
57
|
-
|
|
58
|
-
's'
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
|
|
56
|
+
# Define column names and their data types
|
|
57
|
+
column_dtypes = {
|
|
58
|
+
's': float,
|
|
59
|
+
'u': float,
|
|
60
|
+
'maturity_date': 'datetime64[ns]',
|
|
61
|
+
'dtm': float,
|
|
62
|
+
'ytm': float,
|
|
63
|
+
'a': float,
|
|
64
|
+
'b': float,
|
|
65
|
+
'rho': float,
|
|
66
|
+
'm': float,
|
|
67
|
+
'sigma': float,
|
|
68
|
+
'nu': float,
|
|
69
|
+
'psi': float,
|
|
70
|
+
'p': float,
|
|
71
|
+
'c': float,
|
|
72
|
+
'nu_tilde': float,
|
|
73
|
+
'oi': float,
|
|
74
|
+
'volume': float,
|
|
75
|
+
'r': float,
|
|
76
|
+
'fit_success': bool,
|
|
77
|
+
'cost': float,
|
|
78
|
+
'optimality': float,
|
|
79
|
+
'rmse': float,
|
|
80
|
+
'mae': float,
|
|
81
|
+
'r2': float,
|
|
82
|
+
'max_error': float,
|
|
83
|
+
'n_points': int
|
|
84
|
+
}
|
|
65
85
|
|
|
66
86
|
# Get unique maturities and sort them
|
|
67
87
|
unique_ytms = sorted(option_chain['ytm'].unique())
|
|
68
88
|
maturity_names = [option_chain[option_chain['ytm'] == ytm]['maturity_name'].iloc[0] for ytm in unique_ytms]
|
|
69
89
|
|
|
70
|
-
#
|
|
71
|
-
|
|
90
|
+
# Store results in a dictionary first
|
|
91
|
+
results_data = {col: [] for col in column_dtypes.keys()}
|
|
72
92
|
|
|
73
93
|
# ANSI color codes for terminal output
|
|
74
94
|
GREEN, RED, RESET = '\033[32m', '\033[31m', '\033[0m'
|
|
@@ -119,21 +139,50 @@ def fit_model(option_chain: pd.DataFrame,
|
|
|
119
139
|
# Calculate Jump-Wing parameters
|
|
120
140
|
nu, psi, p, c, nu_tilde = SVIModel.raw_to_jw_params(a, b, sigma, rho, m, ytm)
|
|
121
141
|
|
|
122
|
-
# Store
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
]
|
|
142
|
+
# Store values in the results dictionary with proper types
|
|
143
|
+
results_data['s'].append(float(s))
|
|
144
|
+
results_data['u'].append(float(u))
|
|
145
|
+
results_data['maturity_date'].append(maturity_data['maturity_date'].iloc[0])
|
|
146
|
+
results_data['dtm'].append(float(dtm))
|
|
147
|
+
results_data['ytm'].append(float(ytm))
|
|
148
|
+
results_data['a'].append(float(a))
|
|
149
|
+
results_data['b'].append(float(b))
|
|
150
|
+
results_data['rho'].append(float(rho))
|
|
151
|
+
results_data['m'].append(float(m))
|
|
152
|
+
results_data['sigma'].append(float(sigma))
|
|
153
|
+
results_data['nu'].append(float(nu))
|
|
154
|
+
results_data['psi'].append(float(psi))
|
|
155
|
+
results_data['p'].append(float(p))
|
|
156
|
+
results_data['c'].append(float(c))
|
|
157
|
+
results_data['nu_tilde'].append(float(nu_tilde))
|
|
158
|
+
results_data['oi'].append(float(oi))
|
|
159
|
+
results_data['volume'].append(float(volume))
|
|
160
|
+
results_data['r'].append(float(r))
|
|
161
|
+
results_data['fit_success'].append(bool(result.success))
|
|
162
|
+
results_data['cost'].append(float(result.cost))
|
|
163
|
+
results_data['optimality'].append(float(result.optimality))
|
|
164
|
+
results_data['rmse'].append(float(rmse))
|
|
165
|
+
results_data['mae'].append(float(mae))
|
|
166
|
+
results_data['r2'].append(float(r2))
|
|
167
|
+
results_data['max_error'].append(float(max_error))
|
|
168
|
+
results_data['n_points'].append(int(len(maturity_data)))
|
|
131
169
|
|
|
132
170
|
# Log result
|
|
133
171
|
status = f'{GREEN}SUCCESS{RESET}' if result.success else f'{RED}FAILED{RESET}'
|
|
134
172
|
logger.info(f'Optimization for {maturity_name}: {status}')
|
|
135
173
|
logger.info('-------------------------------------')
|
|
136
174
|
|
|
175
|
+
# Create DataFrame with proper types
|
|
176
|
+
results_df = pd.DataFrame(results_data, index=maturity_names)
|
|
177
|
+
|
|
178
|
+
# Convert columns to appropriate types
|
|
179
|
+
for col, dtype in column_dtypes.items():
|
|
180
|
+
if col in results_df.columns:
|
|
181
|
+
try:
|
|
182
|
+
results_df[col] = results_df[col].astype(dtype)
|
|
183
|
+
except (ValueError, TypeError) as e:
|
|
184
|
+
logger.warning(f"Could not convert column {col} to {dtype}: {e}")
|
|
185
|
+
|
|
137
186
|
return results_df
|
|
138
187
|
|
|
139
188
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|