voly 0.0.40__tar.gz → 0.0.42__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.40/src/voly.egg-info → voly-0.0.42}/PKG-INFO +1 -1
 - {voly-0.0.40 → voly-0.0.42}/pyproject.toml +2 -2
 - {voly-0.0.40 → voly-0.0.42}/src/voly/core/charts.py +30 -36
 - {voly-0.0.40 → voly-0.0.42/src/voly.egg-info}/PKG-INFO +1 -1
 - {voly-0.0.40 → voly-0.0.42}/LICENSE +0 -0
 - {voly-0.0.40 → voly-0.0.42}/README.md +0 -0
 - {voly-0.0.40 → voly-0.0.42}/setup.cfg +0 -0
 - {voly-0.0.40 → voly-0.0.42}/setup.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/__init__.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/client.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/core/__init__.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/core/data.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/core/fit.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/core/interpolate.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/core/rnd.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/exceptions.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/formulas.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/models.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/utils/__init__.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly/utils/logger.py +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly.egg-info/SOURCES.txt +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly.egg-info/dependency_links.txt +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly.egg-info/requires.txt +0 -0
 - {voly-0.0.40 → voly-0.0.42}/src/voly.egg-info/top_level.txt +0 -0
 - {voly-0.0.40 → voly-0.0.42}/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.42"
         
     | 
| 
       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.42"
         
     | 
| 
       64 
64 
     | 
    
         
             
            warn_return_any = true
         
     | 
| 
       65 
65 
     | 
    
         
             
            warn_unused_configs = true
         
     | 
| 
       66 
66 
     | 
    
         
             
            disallow_untyped_defs = true
         
     | 
| 
         @@ -22,20 +22,19 @@ pio.renderers.default = "browser" 
     | 
|
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
            @catch_exception
         
     | 
| 
       25 
     | 
    
         
            -
            def plot_volatility_smile( 
     | 
| 
       26 
     | 
    
         
            -
                                       
     | 
| 
       27 
     | 
    
         
            -
                                      market_data:  
     | 
| 
       28 
     | 
    
         
            -
                                       
     | 
| 
       29 
     | 
    
         
            -
                                       
     | 
| 
      
 25 
     | 
    
         
            +
            def plot_volatility_smile(moneyness_array: np.ndarray,
         
     | 
| 
      
 26 
     | 
    
         
            +
                                      iv_array: np.ndarray,
         
     | 
| 
      
 27 
     | 
    
         
            +
                                      market_data: pd.DataFrame = None,
         
     | 
| 
      
 28 
     | 
    
         
            +
                                      maturity: Optional[float] = None,
         
     | 
| 
      
 29 
     | 
    
         
            +
                                      ) -> go.Figure:
         
     | 
| 
       30 
30 
     | 
    
         
             
                """
         
     | 
| 
       31 
31 
     | 
    
         
             
                Plot volatility smile for a single expiry.
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                Parameters:
         
     | 
| 
       34 
     | 
    
         
            -
                -  
     | 
| 
       35 
     | 
    
         
            -
                -  
     | 
| 
      
 34 
     | 
    
         
            +
                - moneyness_array: Moneyness grid
         
     | 
| 
      
 35 
     | 
    
         
            +
                - iv_array: Implied volatility values
         
     | 
| 
       36 
36 
     | 
    
         
             
                - market_data: Optional market data for comparison
         
     | 
| 
       37 
     | 
    
         
            -
                -  
     | 
| 
       38 
     | 
    
         
            -
                - title: Optional plot title
         
     | 
| 
      
 37 
     | 
    
         
            +
                - maturity: Maturity name for filtering market data
         
     | 
| 
       39 
38 
     | 
    
         | 
| 
       40 
39 
     | 
    
         
             
                Returns:
         
     | 
| 
       41 
40 
     | 
    
         
             
                - Plotly figure
         
     | 
| 
         @@ -45,8 +44,8 @@ def plot_volatility_smile(moneyness: np.ndarray, 
     | 
|
| 
       45 
44 
     | 
    
         
             
                # Add model curve
         
     | 
| 
       46 
45 
     | 
    
         
             
                fig.add_trace(
         
     | 
| 
       47 
46 
     | 
    
         
             
                    go.Scatter(
         
     | 
| 
       48 
     | 
    
         
            -
                        x= 
     | 
| 
       49 
     | 
    
         
            -
                        y= 
     | 
| 
      
 47 
     | 
    
         
            +
                        x=moneyness_array,
         
     | 
| 
      
 48 
     | 
    
         
            +
                        y=iv_array * 100,  # Convert to percentage
         
     | 
| 
       50 
49 
     | 
    
         
             
                        mode='lines',
         
     | 
| 
       51 
50 
     | 
    
         
             
                        name='Model',
         
     | 
| 
       52 
51 
     | 
    
         
             
                        line=dict(color='#0080FF', width=2)
         
     | 
| 
         @@ -54,14 +53,14 @@ def plot_volatility_smile(moneyness: np.ndarray, 
     | 
|
| 
       54 
53 
     | 
    
         
             
                )
         
     | 
| 
       55 
54 
     | 
    
         | 
| 
       56 
55 
     | 
    
         
             
                # Filter market data for the specific expiry
         
     | 
| 
       57 
     | 
    
         
            -
                 
     | 
| 
      
 56 
     | 
    
         
            +
                maturity_data = market_data[market_data['maturity_name'] == maturity]
         
     | 
| 
       58 
57 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                if not  
     | 
| 
      
 58 
     | 
    
         
            +
                if not maturity_data.empty:
         
     | 
| 
       60 
59 
     | 
    
         
             
                    # Add bid IV
         
     | 
| 
       61 
60 
     | 
    
         
             
                    fig.add_trace(
         
     | 
| 
       62 
61 
     | 
    
         
             
                        go.Scatter(
         
     | 
| 
       63 
     | 
    
         
            -
                            x= 
     | 
| 
       64 
     | 
    
         
            -
                            y= 
     | 
| 
      
 62 
     | 
    
         
            +
                            x=maturity_data['log_moneyness'],
         
     | 
| 
      
 63 
     | 
    
         
            +
                            y=maturity_data['bid_iv'] * 100,  # Convert to percentage
         
     | 
| 
       65 
64 
     | 
    
         
             
                            mode='markers',
         
     | 
| 
       66 
65 
     | 
    
         
             
                            name='Bid IV',
         
     | 
| 
       67 
66 
     | 
    
         
             
                            marker=dict(size=8, symbol='circle', opacity=0.7)
         
     | 
| 
         @@ -71,23 +70,19 @@ def plot_volatility_smile(moneyness: np.ndarray, 
     | 
|
| 
       71 
70 
     | 
    
         
             
                    # Add ask IV
         
     | 
| 
       72 
71 
     | 
    
         
             
                    fig.add_trace(
         
     | 
| 
       73 
72 
     | 
    
         
             
                        go.Scatter(
         
     | 
| 
       74 
     | 
    
         
            -
                            x= 
     | 
| 
       75 
     | 
    
         
            -
                            y= 
     | 
| 
      
 73 
     | 
    
         
            +
                            x=maturity_data['log_moneyness'],
         
     | 
| 
      
 74 
     | 
    
         
            +
                            y=maturity_data['ask_iv'] * 100,  # Convert to percentage
         
     | 
| 
       76 
75 
     | 
    
         
             
                            mode='markers',
         
     | 
| 
       77 
76 
     | 
    
         
             
                            name='Ask IV',
         
     | 
| 
       78 
77 
     | 
    
         
             
                            marker=dict(size=8, symbol='circle', opacity=0.7)
         
     | 
| 
       79 
78 
     | 
    
         
             
                        )
         
     | 
| 
       80 
79 
     | 
    
         
             
                    )
         
     | 
| 
       81 
80 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                    if title is None:
         
     | 
| 
       84 
     | 
    
         
            -
                        maturity_name = expiry_data['maturity_name'].iloc[0]
         
     | 
| 
       85 
     | 
    
         
            -
                        dte_value = expiry_data['dte'].iloc[0]
         
     | 
| 
       86 
     | 
    
         
            -
                        title = f'Vol Smile for {maturity_name} (DTE: {dte_value:.1f})'
         
     | 
| 
      
 81 
     | 
    
         
            +
                dte_value = maturity_data['dte'].iloc[0]
         
     | 
| 
       87 
82 
     | 
    
         | 
| 
       88 
83 
     | 
    
         
             
                # Update layout
         
     | 
| 
       89 
84 
     | 
    
         
             
                fig.update_layout(
         
     | 
| 
       90 
     | 
    
         
            -
                    title= 
     | 
| 
      
 85 
     | 
    
         
            +
                    title=f'Vol Smile for {maturity} (DTE: {dte_value:.1f})',
         
     | 
| 
       91 
86 
     | 
    
         
             
                    xaxis_title='Log Moneyness',
         
     | 
| 
       92 
87 
     | 
    
         
             
                    yaxis_title='Implied Volatility (%)',
         
     | 
| 
       93 
88 
     | 
    
         
             
                    template='plotly_dark',
         
     | 
| 
         @@ -98,7 +93,7 @@ def plot_volatility_smile(moneyness: np.ndarray, 
     | 
|
| 
       98 
93 
     | 
    
         | 
| 
       99 
94 
     | 
    
         | 
| 
       100 
95 
     | 
    
         
             
            @catch_exception
         
     | 
| 
       101 
     | 
    
         
            -
            def plot_all_smiles( 
     | 
| 
      
 96 
     | 
    
         
            +
            def plot_all_smiles(moneyness_array: np.ndarray,
         
     | 
| 
       102 
97 
     | 
    
         
             
                                iv_surface: Dict[float, np.ndarray],
         
     | 
| 
       103 
98 
     | 
    
         
             
                                market_data: Optional[pd.DataFrame] = None) -> List[go.Figure]:
         
     | 
| 
       104 
99 
     | 
    
         
             
                """
         
     | 
| 
         @@ -114,16 +109,16 @@ def plot_all_smiles(moneyness: np.ndarray, 
     | 
|
| 
       114 
109 
     | 
    
         
             
                """
         
     | 
| 
       115 
110 
     | 
    
         
             
                figures = []
         
     | 
| 
       116 
111 
     | 
    
         | 
| 
       117 
     | 
    
         
            -
                #  
     | 
| 
       118 
     | 
    
         
            -
                 
     | 
| 
      
 112 
     | 
    
         
            +
                # Get maturities
         
     | 
| 
      
 113 
     | 
    
         
            +
                maturities = list(iv_surface.keys())
         
     | 
| 
       119 
114 
     | 
    
         | 
| 
       120 
115 
     | 
    
         
             
                # Create a figure for each expiry
         
     | 
| 
       121 
     | 
    
         
            -
                for  
     | 
| 
      
 116 
     | 
    
         
            +
                for maturity in maturities:
         
     | 
| 
       122 
117 
     | 
    
         
             
                    fig = plot_volatility_smile(
         
     | 
| 
       123 
     | 
    
         
            -
                         
     | 
| 
       124 
     | 
    
         
            -
                         
     | 
| 
      
 118 
     | 
    
         
            +
                        moneyness_array=moneyness_array,
         
     | 
| 
      
 119 
     | 
    
         
            +
                        iv_array=iv_surface[maturity],
         
     | 
| 
       125 
120 
     | 
    
         
             
                        market_data=market_data,
         
     | 
| 
       126 
     | 
    
         
            -
                         
     | 
| 
      
 121 
     | 
    
         
            +
                        maturity=maturity
         
     | 
| 
       127 
122 
     | 
    
         
             
                    )
         
     | 
| 
       128 
123 
     | 
    
         
             
                    figures.append(fig)
         
     | 
| 
       129 
124 
     | 
    
         | 
| 
         @@ -383,7 +378,7 @@ def plot_3d_surface(moneyness_array: np.ndarray, 
     | 
|
| 
       383 
378 
     | 
    
         
             
                    template='plotly_dark',
         
     | 
| 
       384 
379 
     | 
    
         
             
                    scene=dict(
         
     | 
| 
       385 
380 
     | 
    
         
             
                        xaxis_title='Log Moneyness',
         
     | 
| 
       386 
     | 
    
         
            -
                        yaxis_title=' 
     | 
| 
      
 381 
     | 
    
         
            +
                        yaxis_title='Maturities',
         
     | 
| 
       387 
382 
     | 
    
         
             
                        zaxis_title='Implied Volatility (%)'
         
     | 
| 
       388 
383 
     | 
    
         
             
                    ),
         
     | 
| 
       389 
384 
     | 
    
         
             
                    margin=dict(l=65, r=50, b=65, t=90)
         
     | 
| 
         @@ -395,8 +390,7 @@ def plot_3d_surface(moneyness_array: np.ndarray, 
     | 
|
| 
       395 
390 
     | 
    
         
             
            @catch_exception
         
     | 
| 
       396 
391 
     | 
    
         
             
            def plot_rnd(moneyness_array: np.ndarray,
         
     | 
| 
       397 
392 
     | 
    
         
             
                         rnd_values: np.ndarray,
         
     | 
| 
       398 
     | 
    
         
            -
                         spot_price: float = 1.0 
     | 
| 
       399 
     | 
    
         
            -
                         title: str = 'Risk-Neutral Density') -> go.Figure:
         
     | 
| 
      
 393 
     | 
    
         
            +
                         spot_price: float = 1.0) -> go.Figure:
         
     | 
| 
       400 
394 
     | 
    
         
             
                """
         
     | 
| 
       401 
395 
     | 
    
         
             
                Plot risk-neutral density (RND).
         
     | 
| 
       402 
396 
     | 
    
         | 
| 
         @@ -452,7 +446,7 @@ def plot_rnd(moneyness_array: np.ndarray, 
     | 
|
| 
       452 
446 
     | 
    
         | 
| 
       453 
447 
     | 
    
         
             
                # Update layout
         
     | 
| 
       454 
448 
     | 
    
         
             
                fig.update_layout(
         
     | 
| 
       455 
     | 
    
         
            -
                    title= 
     | 
| 
      
 449 
     | 
    
         
            +
                    title='Risk-Neutral Density',
         
     | 
| 
       456 
450 
     | 
    
         
             
                    xaxis_title='Price',
         
     | 
| 
       457 
451 
     | 
    
         
             
                    yaxis_title='Density',
         
     | 
| 
       458 
452 
     | 
    
         
             
                    template='plotly_dark',
         
     | 
| 
         @@ -465,7 +459,7 @@ def plot_rnd(moneyness_array: np.ndarray, 
     | 
|
| 
       465 
459 
     | 
    
         
             
            @catch_exception
         
     | 
| 
       466 
460 
     | 
    
         
             
            def plot_rnd_all_expiries(moneyness_array: np.ndarray,
         
     | 
| 
       467 
461 
     | 
    
         
             
                                      rnd_surface: Dict[str, np.ndarray],
         
     | 
| 
       468 
     | 
    
         
            -
                                       
     | 
| 
      
 462 
     | 
    
         
            +
                                      fit_results: Dict[str, Any],
         
     | 
| 
       469 
463 
     | 
    
         
             
                                      spot_price: float = 1.0) -> go.Figure:
         
     | 
| 
       470 
464 
     | 
    
         
             
                """
         
     | 
| 
       471 
465 
     | 
    
         
             
                Plot risk-neutral densities for all expiries.
         
     | 
| 
         @@ -480,7 +474,7 @@ def plot_rnd_all_expiries(moneyness_array: np.ndarray, 
     | 
|
| 
       480 
474 
     | 
    
         
             
                - Plotly figure
         
     | 
| 
       481 
475 
     | 
    
         
             
                """
         
     | 
| 
       482 
476 
     | 
    
         
             
                # Get maturity information
         
     | 
| 
       483 
     | 
    
         
            -
                dte_values =  
     | 
| 
      
 477 
     | 
    
         
            +
                dte_values = fit_results['fit_performance']['DTE']
         
     | 
| 
       484 
478 
     | 
    
         | 
| 
       485 
479 
     | 
    
         
             
                # Create figure
         
     | 
| 
       486 
480 
     | 
    
         
             
                fig = go.Figure()
         
     | 
| 
         
            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
         
     |