voly 0.0.152__py3-none-any.whl → 0.0.153__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 CHANGED
@@ -23,8 +23,7 @@ from voly.core.rnd import get_rnd_surface
23
23
  from voly.core.hd import get_historical_data, get_hd_surface
24
24
  from voly.core.interpolate import interpolate_model
25
25
  from voly.core.charts import (
26
- plot_all_smiles, plot_raw_parameters, plot_jw_parameters, plot_fit_performance, plot_3d_surface,
27
- plot_fit_performance
26
+ plot_all_smiles, plot_raw_parameters, plot_jw_parameters, plot_fit_performance, plot_3d_surface
28
27
  )
29
28
 
30
29
 
@@ -156,10 +155,6 @@ class VolyClient:
156
155
  option_type: str = 'call') -> float:
157
156
  return iv(option_price, s, K, r, t, option_type)
158
157
 
159
- @staticmethod
160
- def pdf_to_calls(pdf_K: np.ndarray, s: float, K: np.ndarray, r: float, t: float):
161
- return pdf_to_calls(pdf_K, s, K, r, t)
162
-
163
158
  # -------------------------------------------------------------------------
164
159
  # Model Fitting
165
160
  # -------------------------------------------------------------------------
@@ -307,8 +302,19 @@ class VolyClient:
307
302
  def get_rnd_surface(model_results: pd.DataFrame,
308
303
  domain_params: Tuple[float, float, int] = (-1.5, 1.5, 1000),
309
304
  return_domain: str = 'log_moneyness',
310
- method: str = 'rookley') -> Tuple[Dict[str, np.ndarray], Dict[str, np.ndarray], Dict[str, np.ndarray], pd.DataFrame]:
305
+ method: str = 'rookley') -> Dict[str, Any]:
306
+ """
307
+ Generate risk-neutral density surface from volatility surface parameters.
311
308
 
309
+ Parameters:
310
+ - model_results: DataFrame from fit_model() or interpolate_model()
311
+ - domain_params: Tuple of (min_log_moneyness, max_log_moneyness, num_points)
312
+ - return_domain: Domain for results ('log_moneyness', 'moneyness', 'returns', 'strikes')
313
+ - method: Method for RND estimation ('rookley' or 'breeden')
314
+
315
+ Returns:
316
+ - Dictionary with pdf_surface, cdf_surface, x_surface, and moments
317
+ """
312
318
  logger.info("Calculating RND surface")
313
319
 
314
320
  return get_rnd_surface(
@@ -326,41 +332,50 @@ class VolyClient:
326
332
  def get_historical_data(currency: str = 'BTC',
327
333
  lookback_days: str = '90d',
328
334
  granularity: str = '15m',
329
- exchange_name: str = 'binance'):
335
+ exchange_name: str = 'binance') -> pd.DataFrame:
336
+ """
337
+ Fetch historical OHLCV data for a cryptocurrency.
330
338
 
331
- # Generate the surface
332
- df_hist = get_historical_data(
339
+ Parameters:
340
+ - currency: The cryptocurrency to fetch data for (e.g., 'BTC', 'ETH')
341
+ - lookback_days: The lookback period in days, formatted as '90d', '30d', etc.
342
+ - granularity: The time interval for data points (e.g., '15m', '1h', '1d')
343
+ - exchange_name: The exchange to fetch data from (default: 'binance')
344
+
345
+ Returns:
346
+ - Historical price data with OHLCV columns and datetime index
347
+ """
348
+ logger.info(f"Fetching historical {currency} data from {exchange_name}...")
349
+
350
+ return get_historical_data(
333
351
  currency=currency,
334
352
  lookback_days=lookback_days,
335
353
  granularity=granularity,
336
354
  exchange_name=exchange_name
337
355
  )
338
356
 
339
- return df_hist
340
-
341
357
  @staticmethod
342
358
  def get_hd_surface(model_results: pd.DataFrame,
343
359
  df_hist: pd.DataFrame,
344
360
  domain_params: Tuple[float, float, int] = (-1.5, 1.5, 1000),
345
- return_domain: str = 'log_moneyness',
346
- method: str = 'garch',
347
- distribution: str = 'normal',
348
- window_length: str = '30d',
349
- n_fits: int = 400,
350
- simulations: int = 5000,
351
- bandwidth: str = 'silverman') -> Dict[str, Any]:
361
+ return_domain: str = 'log_moneyness') -> Dict[str, Any]:
362
+ """
363
+ Generate historical density surface using normal distributions.
352
364
 
353
- logger.info(f"Calculating historical density surface using {method} method")
365
+ Parameters:
366
+ - model_results: DataFrame with model parameters and maturities
367
+ - df_hist: DataFrame with historical price data
368
+ - domain_params: Tuple of (min_log_moneyness, max_log_moneyness, num_points)
369
+ - return_domain: Domain for results ('log_moneyness', 'moneyness', 'returns', 'strikes')
370
+
371
+ Returns:
372
+ - Dictionary with pdf_surface, cdf_surface, x_surface, and moments
373
+ """
374
+ logger.info("Calculating HD surface")
354
375
 
355
376
  return get_hd_surface(
356
377
  model_results=model_results,
357
378
  df_hist=df_hist,
358
379
  domain_params=domain_params,
359
- return_domain=return_domain,
360
- method=method,
361
- distribution=distribution,
362
- window_length=window_length,
363
- n_fits=n_fits,
364
- simulations=simulations,
365
- bandwidth=bandwidth
380
+ return_domain=return_domain
366
381
  )