voly 0.0.36__tar.gz → 0.0.38__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.36/src/voly.egg-info → voly-0.0.38}/PKG-INFO +1 -1
 - {voly-0.0.36 → voly-0.0.38}/pyproject.toml +2 -2
 - {voly-0.0.36 → voly-0.0.38}/src/voly/client.py +11 -30
 - {voly-0.0.36 → voly-0.0.38}/src/voly/core/fit.py +2 -2
 - {voly-0.0.36 → voly-0.0.38}/src/voly/core/rnd.py +2 -28
 - {voly-0.0.36 → voly-0.0.38/src/voly.egg-info}/PKG-INFO +1 -1
 - {voly-0.0.36 → voly-0.0.38}/LICENSE +0 -0
 - {voly-0.0.36 → voly-0.0.38}/README.md +0 -0
 - {voly-0.0.36 → voly-0.0.38}/setup.cfg +0 -0
 - {voly-0.0.36 → voly-0.0.38}/setup.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/__init__.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/core/__init__.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/core/charts.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/core/data.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/core/interpolate.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/exceptions.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/formulas.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/models.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/utils/__init__.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly/utils/logger.py +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly.egg-info/SOURCES.txt +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly.egg-info/dependency_links.txt +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly.egg-info/requires.txt +0 -0
 - {voly-0.0.36 → voly-0.0.38}/src/voly.egg-info/top_level.txt +0 -0
 - {voly-0.0.36 → voly-0.0.38}/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.38"
         
     | 
| 
       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.38"
         
     | 
| 
       64 
64 
     | 
    
         
             
            warn_return_any = true
         
     | 
| 
       65 
65 
     | 
    
         
             
            warn_unused_configs = true
         
     | 
| 
       66 
66 
     | 
    
         
             
            disallow_untyped_defs = true
         
     | 
| 
         @@ -19,7 +19,7 @@ from voly.formulas import ( 
     | 
|
| 
       19 
19 
     | 
    
         
             
            )
         
     | 
| 
       20 
20 
     | 
    
         
             
            from voly.core.data import fetch_option_chain, process_option_chain
         
     | 
| 
       21 
21 
     | 
    
         
             
            from voly.core.fit import fit_model, get_iv_surface
         
     | 
| 
       22 
     | 
    
         
            -
            from voly.core.rnd import  
     | 
| 
      
 22 
     | 
    
         
            +
            from voly.core.rnd import get_rnd_surface, calculate_pdf, calculate_cdf, calculate_strike_probability
         
     | 
| 
       23 
23 
     | 
    
         
             
            from voly.core.interpolate import interpolate_model
         
     | 
| 
       24 
24 
     | 
    
         
             
            from voly.core.charts import (
         
     | 
| 
       25 
25 
     | 
    
         
             
                plot_all_smiles, plot_3d_surface, plot_parameters, plot_fit_performance,
         
     | 
| 
         @@ -336,12 +336,15 @@ class VolyClient: 
     | 
|
| 
       336 
336 
     | 
    
         
             
                    - Tuple of (moneyness_array, iv_surface)
         
     | 
| 
       337 
337 
     | 
    
         
             
                    """
         
     | 
| 
       338 
338 
     | 
    
         
             
                    # Generate the surface
         
     | 
| 
       339 
     | 
    
         
            -
                    iv_surface = get_iv_surface(
         
     | 
| 
      
 339 
     | 
    
         
            +
                    moneyness_array, iv_surface = get_iv_surface(
         
     | 
| 
       340 
340 
     | 
    
         
             
                        fit_results=fit_results,
         
     | 
| 
       341 
341 
     | 
    
         
             
                        moneyness_params=moneyness_params
         
     | 
| 
       342 
342 
     | 
    
         
             
                    )
         
     | 
| 
       343 
343 
     | 
    
         | 
| 
       344 
     | 
    
         
            -
                    return  
     | 
| 
      
 344 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 345 
     | 
    
         
            +
                        'moneyness_array': moneyness_array,
         
     | 
| 
      
 346 
     | 
    
         
            +
                        'iv_surface': iv_surface
         
     | 
| 
      
 347 
     | 
    
         
            +
                    }
         
     | 
| 
       345 
348 
     | 
    
         | 
| 
       346 
349 
     | 
    
         
             
                @staticmethod
         
     | 
| 
       347 
350 
     | 
    
         
             
                def plot_model(fit_results: Dict[str, Any],
         
     | 
| 
         @@ -386,31 +389,6 @@ class VolyClient: 
     | 
|
| 
       386 
389 
     | 
    
         
             
                # Risk-Neutral Density (RND)
         
     | 
| 
       387 
390 
     | 
    
         
             
                # -------------------------------------------------------------------------
         
     | 
| 
       388 
391 
     | 
    
         | 
| 
       389 
     | 
    
         
            -
                @staticmethod
         
     | 
| 
       390 
     | 
    
         
            -
                def get_rnd(svi_params_list: List[float],
         
     | 
| 
       391 
     | 
    
         
            -
                            moneyness_params: Tuple[float, float, int] = (-2, 2, 500)
         
     | 
| 
       392 
     | 
    
         
            -
                            ) -> np.ndarray:
         
     | 
| 
       393 
     | 
    
         
            -
                    """
         
     | 
| 
       394 
     | 
    
         
            -
                    Calculate risk-neutral density from fitted model.
         
     | 
| 
       395 
     | 
    
         
            -
             
     | 
| 
       396 
     | 
    
         
            -
                    Parameters:
         
     | 
| 
       397 
     | 
    
         
            -
             
     | 
| 
       398 
     | 
    
         
            -
                    Returns:
         
     | 
| 
       399 
     | 
    
         
            -
                    - Array with RND results over moneyness
         
     | 
| 
       400 
     | 
    
         
            -
                    """
         
     | 
| 
       401 
     | 
    
         
            -
                    logger.info("Calculating risk-neutral density")
         
     | 
| 
       402 
     | 
    
         
            -
             
     | 
| 
       403 
     | 
    
         
            -
                    # Generate the surface
         
     | 
| 
       404 
     | 
    
         
            -
                    moneyness_array, rnd_values = get_rnd(
         
     | 
| 
       405 
     | 
    
         
            -
                        svi_params_list=svi_params_list,
         
     | 
| 
       406 
     | 
    
         
            -
                        moneyness_params=moneyness_params
         
     | 
| 
       407 
     | 
    
         
            -
                    )
         
     | 
| 
       408 
     | 
    
         
            -
             
     | 
| 
       409 
     | 
    
         
            -
                    return {
         
     | 
| 
       410 
     | 
    
         
            -
                        'moneyness_array': moneyness_array,
         
     | 
| 
       411 
     | 
    
         
            -
                        'rnd_values': rnd_values
         
     | 
| 
       412 
     | 
    
         
            -
                    }
         
     | 
| 
       413 
     | 
    
         
            -
             
     | 
| 
       414 
392 
     | 
    
         
             
                @staticmethod
         
     | 
| 
       415 
393 
     | 
    
         
             
                def get_rnd_surface(fit_results: Dict[str, Any],
         
     | 
| 
       416 
394 
     | 
    
         
             
                                    moneyness_params: Tuple[float, float, int] = (-2, 2, 500)
         
     | 
| 
         @@ -426,12 +404,15 @@ class VolyClient: 
     | 
|
| 
       426 
404 
     | 
    
         
             
                    logger.info("Calculating risk-neutral density")
         
     | 
| 
       427 
405 
     | 
    
         | 
| 
       428 
406 
     | 
    
         
             
                    # Generate the surface
         
     | 
| 
       429 
     | 
    
         
            -
                     
     | 
| 
      
 407 
     | 
    
         
            +
                    moneyness_array, rnd_surface = get_rnd_surface(
         
     | 
| 
       430 
408 
     | 
    
         
             
                        fit_results=fit_results,
         
     | 
| 
       431 
409 
     | 
    
         
             
                        moneyness_params=moneyness_params
         
     | 
| 
       432 
410 
     | 
    
         
             
                    )
         
     | 
| 
       433 
411 
     | 
    
         | 
| 
       434 
     | 
    
         
            -
                    return  
     | 
| 
      
 412 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 413 
     | 
    
         
            +
                        'moneyness_array': moneyness_array,
         
     | 
| 
      
 414 
     | 
    
         
            +
                        'rnd_surface': rnd_surface
         
     | 
| 
      
 415 
     | 
    
         
            +
                    }
         
     | 
| 
       435 
416 
     | 
    
         | 
| 
       436 
417 
     | 
    
         
             
                @staticmethod
         
     | 
| 
       437 
418 
     | 
    
         
             
                def pdf(rnd_results: Dict[str, Any],
         
     | 
| 
         @@ -276,7 +276,7 @@ def get_iv_surface(fit_results: Dict[str, Any], 
     | 
|
| 
       276 
276 
     | 
    
         
             
                - moneyness_params: Tuple of (min, max, num_points) for the moneyness grid
         
     | 
| 
       277 
277 
     | 
    
         | 
| 
       278 
278 
     | 
    
         
             
                Returns:
         
     | 
| 
       279 
     | 
    
         
            -
                - iv_surface
         
     | 
| 
      
 279 
     | 
    
         
            +
                - moneyness_array, iv_surface
         
     | 
| 
       280 
280 
     | 
    
         
             
                """
         
     | 
| 
       281 
281 
     | 
    
         
             
                iv_surface = {}
         
     | 
| 
       282 
282 
     | 
    
         | 
| 
         @@ -297,4 +297,4 @@ def get_iv_surface(fit_results: Dict[str, Any], 
     | 
|
| 
       297 
297 
     | 
    
         
             
                    w_svi = [SVIModel.svi(x, *svi_params) for x in moneyness_array]
         
     | 
| 
       298 
298 
     | 
    
         
             
                    iv_surface[yte] = np.sqrt(np.array(w_svi) / yte)
         
     | 
| 
       299 
299 
     | 
    
         | 
| 
       300 
     | 
    
         
            -
                return iv_surface
         
     | 
| 
      
 300 
     | 
    
         
            +
                return moneyness_array, iv_surface
         
     | 
| 
         @@ -16,32 +16,6 @@ def rnd(moneyness_array: float, total_var: float) -> float: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                return np.exp(-(moneyness_array ** 2) / (2 * total_var)) / (np.sqrt(2 * np.pi * total_var))
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
            @catch_exception
         
     | 
| 
       20 
     | 
    
         
            -
            def get_rnd(svi_params_list: List[float],
         
     | 
| 
       21 
     | 
    
         
            -
                        moneyness_params: Tuple[float, float, int] = (-2, 2, 500)
         
     | 
| 
       22 
     | 
    
         
            -
                        ) -> Dict[str, Any]:
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                # Adjust parameter order to match function signatures
         
     | 
| 
       25 
     | 
    
         
            -
                a, b, sigma, rho, m = svi_params_list
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                # Extract moneyness parameters
         
     | 
| 
       28 
     | 
    
         
            -
                min_m, max_m, num_points = moneyness_params
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                # Generate moneyness grid
         
     | 
| 
       31 
     | 
    
         
            -
                moneyness_array = np.linspace(min_m, max_m, num=num_points)
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                # Calculate total variance
         
     | 
| 
       34 
     | 
    
         
            -
                total_var = np.array([SVIModel.svi(x, a, b, sigma, rho, m) for x in moneyness_array])
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                # Calculate risk-neutral density using the base RND function
         
     | 
| 
       37 
     | 
    
         
            -
                rnd_values = np.array([rnd(x, var) for x, var in zip(moneyness_array, total_var)])
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                return {
         
     | 
| 
       40 
     | 
    
         
            -
                    'moneyness_array': moneyness_array,
         
     | 
| 
       41 
     | 
    
         
            -
                    'rnd_values': rnd_values
         
     | 
| 
       42 
     | 
    
         
            -
                }
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
19 
     | 
    
         
             
            @catch_exception
         
     | 
| 
       46 
20 
     | 
    
         
             
            def get_rnd_surface(fit_results: Dict[str, Any],
         
     | 
| 
       47 
21 
     | 
    
         
             
                                moneyness_params: Tuple[float, float, int] = (-2, 2, 500)
         
     | 
| 
         @@ -54,7 +28,7 @@ def get_rnd_surface(fit_results: Dict[str, Any], 
     | 
|
| 
       54 
28 
     | 
    
         
             
                - fit_results: results from fit_model()
         
     | 
| 
       55 
29 
     | 
    
         | 
| 
       56 
30 
     | 
    
         
             
                Returns:
         
     | 
| 
       57 
     | 
    
         
            -
                -  
     | 
| 
      
 31 
     | 
    
         
            +
                - moneyness_array, rnd_surface
         
     | 
| 
       58 
32 
     | 
    
         
             
                """
         
     | 
| 
       59 
33 
     | 
    
         
             
                rnd_surface = {}
         
     | 
| 
       60 
34 
     | 
    
         | 
| 
         @@ -84,7 +58,7 @@ def get_rnd_surface(fit_results: Dict[str, Any], 
     | 
|
| 
       84 
58 
     | 
    
         | 
| 
       85 
59 
     | 
    
         
             
                    rnd_surface[maturity_name] = rnd_values
         
     | 
| 
       86 
60 
     | 
    
         | 
| 
       87 
     | 
    
         
            -
                return rnd_surface
         
     | 
| 
      
 61 
     | 
    
         
            +
                return moneyness_array, rnd_surface
         
     | 
| 
       88 
62 
     | 
    
         | 
| 
       89 
63 
     | 
    
         | 
| 
       90 
64 
     | 
    
         
             
            @catch_exception
         
     | 
| 
         
            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
         
     |