voly 0.0.36__py3-none-any.whl → 0.0.38__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 +11 -30
 - voly/core/fit.py +2 -2
 - voly/core/rnd.py +2 -28
 - {voly-0.0.36.dist-info → voly-0.0.38.dist-info}/METADATA +1 -1
 - {voly-0.0.36.dist-info → voly-0.0.38.dist-info}/RECORD +8 -8
 - {voly-0.0.36.dist-info → voly-0.0.38.dist-info}/LICENSE +0 -0
 - {voly-0.0.36.dist-info → voly-0.0.38.dist-info}/WHEEL +0 -0
 - {voly-0.0.36.dist-info → voly-0.0.38.dist-info}/top_level.txt +0 -0
 
    
        voly/client.py
    CHANGED
    
    | 
         @@ -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],
         
     | 
    
        voly/core/fit.py
    CHANGED
    
    | 
         @@ -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
         
     | 
    
        voly/core/rnd.py
    CHANGED
    
    | 
         @@ -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
         
     | 
| 
         @@ -1,18 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
         
     | 
| 
       2 
     | 
    
         
            -
            voly/client.py,sha256= 
     | 
| 
      
 2 
     | 
    
         
            +
            voly/client.py,sha256=8nBT2cbjSCYn9Qf1xEFMifmlggkg7BI9ANFVNhHYKUI,19171
         
     | 
| 
       3 
3 
     | 
    
         
             
            voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
         
     | 
| 
       4 
4 
     | 
    
         
             
            voly/formulas.py,sha256=7NQZtYWFT_VOyAVNQHLB5-8caGAdtzU8y8eFcYJsZn8,7256
         
     | 
| 
       5 
5 
     | 
    
         
             
            voly/models.py,sha256=YJ12aamLz_-aOni4Qm0_XV9u4bjKK3vfJz0J2gc1h0o,3565
         
     | 
| 
       6 
6 
     | 
    
         
             
            voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
         
     | 
| 
       7 
7 
     | 
    
         
             
            voly/core/charts.py,sha256=lHiDYKb4uHK2R7wjs8xuxQ6FD9QsQyFR2-6bbtxqquE,26696
         
     | 
| 
       8 
8 
     | 
    
         
             
            voly/core/data.py,sha256=Dfk-ByHpdteUiLXr0p-wRLr3VAmdyjdDBKwjwdTgCjA,9939
         
     | 
| 
       9 
     | 
    
         
            -
            voly/core/fit.py,sha256= 
     | 
| 
      
 9 
     | 
    
         
            +
            voly/core/fit.py,sha256=LVu_bgYJppH9Sboh1ovQv5BnJnCxSyNSX7lCpv0NnYk,9945
         
     | 
| 
       10 
10 
     | 
    
         
             
            voly/core/interpolate.py,sha256=ztVIePJZOh-CIbn69wkh1JW2rKywNe2FEewRN0zcSAo,8185
         
     | 
| 
       11 
     | 
    
         
            -
            voly/core/rnd.py,sha256= 
     | 
| 
      
 11 
     | 
    
         
            +
            voly/core/rnd.py,sha256=0jiBkDDy6d_AQggCZsmkd1ilWp4wzAoeCGn_rKybsSA,11897
         
     | 
| 
       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.38.dist-info/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
         
     | 
| 
      
 15 
     | 
    
         
            +
            voly-0.0.38.dist-info/METADATA,sha256=ABlHe4U0hIrdrV9C3N9CrzvA41_SAT5FaZvt1tApp6Y,4092
         
     | 
| 
      
 16 
     | 
    
         
            +
            voly-0.0.38.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
         
     | 
| 
      
 17 
     | 
    
         
            +
            voly-0.0.38.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
         
     | 
| 
      
 18 
     | 
    
         
            +
            voly-0.0.38.dist-info/RECORD,,
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |