voly 0.0.42__tar.gz → 0.0.43__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.42/src/voly.egg-info → voly-0.0.43}/PKG-INFO +1 -1
 - {voly-0.0.42 → voly-0.0.43}/pyproject.toml +2 -2
 - {voly-0.0.42 → voly-0.0.43}/src/voly/formulas.py +39 -0
 - {voly-0.0.42 → voly-0.0.43/src/voly.egg-info}/PKG-INFO +1 -1
 - {voly-0.0.42 → voly-0.0.43}/LICENSE +0 -0
 - {voly-0.0.42 → voly-0.0.43}/README.md +0 -0
 - {voly-0.0.42 → voly-0.0.43}/setup.cfg +0 -0
 - {voly-0.0.42 → voly-0.0.43}/setup.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/__init__.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/client.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/core/__init__.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/core/charts.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/core/data.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/core/fit.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/core/interpolate.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/core/rnd.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/exceptions.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/models.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/utils/__init__.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly/utils/logger.py +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly.egg-info/SOURCES.txt +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly.egg-info/dependency_links.txt +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly.egg-info/requires.txt +0 -0
 - {voly-0.0.42 → voly-0.0.43}/src/voly.egg-info/top_level.txt +0 -0
 - {voly-0.0.42 → voly-0.0.43}/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.43"
         
     | 
| 
       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.43"
         
     | 
| 
       64 
64 
     | 
    
         
             
            warn_return_any = true
         
     | 
| 
       65 
65 
     | 
    
         
             
            warn_unused_configs = true
         
     | 
| 
       66 
66 
     | 
    
         
             
            disallow_untyped_defs = true
         
     | 
| 
         @@ -10,12 +10,40 @@ from voly.models import SVIModel 
     | 
|
| 
       10 
10 
     | 
    
         
             
            from math import exp
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         | 
| 
      
 13 
     | 
    
         
            +
            @catch_exception
         
     | 
| 
      
 14 
     | 
    
         
            +
            def vectorize_inputs(func):
         
     | 
| 
      
 15 
     | 
    
         
            +
                """
         
     | 
| 
      
 16 
     | 
    
         
            +
                Decorator to vectorize Black-Scholes functions to handle both scalar and array inputs.
         
     | 
| 
      
 17 
     | 
    
         
            +
                """
         
     | 
| 
      
 18 
     | 
    
         
            +
                def wrapper(s, k, r, vol, t, option_type='call'):
         
     | 
| 
      
 19 
     | 
    
         
            +
                    # Check if inputs are scalar
         
     | 
| 
      
 20 
     | 
    
         
            +
                    k_scalar = np.isscalar(k)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    vol_scalar = np.isscalar(vol)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    # If both inputs are scalar, use the original function directly
         
     | 
| 
      
 24 
     | 
    
         
            +
                    if k_scalar and vol_scalar:
         
     | 
| 
      
 25 
     | 
    
         
            +
                        return func(s, k, r, vol, t, option_type)
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    # Use NumPy's vectorize to handle array inputs
         
     | 
| 
      
 28 
     | 
    
         
            +
                    vectorized_func = np.vectorize(lambda k_val, vol_val:
         
     | 
| 
      
 29 
     | 
    
         
            +
                                                   func(s, k_val, r, vol_val, t, option_type))
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    # Call the vectorized function with the inputs
         
     | 
| 
      
 32 
     | 
    
         
            +
                    return vectorized_func(k, vol)
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                return wrapper
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            @catch_exception
         
     | 
| 
      
 38 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       13 
39 
     | 
    
         
             
            def d1(s: float, k: float, r: float, vol: float, t: float) -> float:
         
     | 
| 
       14 
40 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       15 
41 
     | 
    
         
             
                    return np.nan
         
     | 
| 
       16 
42 
     | 
    
         
             
                return (np.log(s / k) + (r + vol * vol / 2) * t) / (vol * np.sqrt(t))
         
     | 
| 
       17 
43 
     | 
    
         | 
| 
       18 
44 
     | 
    
         | 
| 
      
 45 
     | 
    
         
            +
            @catch_exception
         
     | 
| 
      
 46 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       19 
47 
     | 
    
         
             
            def d2(s: float, k: float, r: float, vol: float, t: float) -> float:
         
     | 
| 
       20 
48 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       21 
49 
     | 
    
         
             
                    return np.nan
         
     | 
| 
         @@ -23,6 +51,7 @@ def d2(s: float, k: float, r: float, vol: float, t: float) -> float: 
     | 
|
| 
       23 
51 
     | 
    
         | 
| 
       24 
52 
     | 
    
         | 
| 
       25 
53 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 54 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       26 
55 
     | 
    
         
             
            def bs(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
         
     | 
| 
       27 
56 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       28 
57 
     | 
    
         
             
                    # Intrinsic value at expiry
         
     | 
| 
         @@ -41,6 +70,7 @@ def bs(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'c 
     | 
|
| 
       41 
70 
     | 
    
         | 
| 
       42 
71 
     | 
    
         | 
| 
       43 
72 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 73 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       44 
74 
     | 
    
         
             
            def delta(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
         
     | 
| 
       45 
75 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       46 
76 
     | 
    
         
             
                    # At expiry, delta is either 0 or 1 for call, 0 or -1 for put
         
     | 
| 
         @@ -58,6 +88,7 @@ def delta(s: float, k: float, r: float, vol: float, t: float, option_type: str = 
     | 
|
| 
       58 
88 
     | 
    
         | 
| 
       59 
89 
     | 
    
         | 
| 
       60 
90 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 91 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       61 
92 
     | 
    
         
             
            def gamma(s: float, k: float, r: float, vol: float, t: float) -> float:
         
     | 
| 
       62 
93 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       63 
94 
     | 
    
         
             
                    return 0.0
         
     | 
| 
         @@ -67,6 +98,7 @@ def gamma(s: float, k: float, r: float, vol: float, t: float) -> float: 
     | 
|
| 
       67 
98 
     | 
    
         | 
| 
       68 
99 
     | 
    
         | 
| 
       69 
100 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 101 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       70 
102 
     | 
    
         
             
            def vega(s: float, k: float, r: float, vol: float, t: float) -> float:
         
     | 
| 
       71 
103 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       72 
104 
     | 
    
         
             
                    return 0.0
         
     | 
| 
         @@ -76,6 +108,7 @@ def vega(s: float, k: float, r: float, vol: float, t: float) -> float: 
     | 
|
| 
       76 
108 
     | 
    
         | 
| 
       77 
109 
     | 
    
         | 
| 
       78 
110 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 111 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       79 
112 
     | 
    
         
             
            def theta(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
         
     | 
| 
       80 
113 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       81 
114 
     | 
    
         
             
                    return 0.0
         
     | 
| 
         @@ -97,6 +130,7 @@ def theta(s: float, k: float, r: float, vol: float, t: float, option_type: str = 
     | 
|
| 
       97 
130 
     | 
    
         | 
| 
       98 
131 
     | 
    
         | 
| 
       99 
132 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 133 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       100 
134 
     | 
    
         
             
            def rho(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
         
     | 
| 
       101 
135 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       102 
136 
     | 
    
         
             
                    return 0.0
         
     | 
| 
         @@ -110,6 +144,7 @@ def rho(s: float, k: float, r: float, vol: float, t: float, option_type: str = ' 
     | 
|
| 
       110 
144 
     | 
    
         | 
| 
       111 
145 
     | 
    
         | 
| 
       112 
146 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 147 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       113 
148 
     | 
    
         
             
            def vanna(s: float, k: float, r: float, vol: float, t: float) -> float:
         
     | 
| 
       114 
149 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       115 
150 
     | 
    
         
             
                    return 0.0
         
     | 
| 
         @@ -121,6 +156,7 @@ def vanna(s: float, k: float, r: float, vol: float, t: float) -> float: 
     | 
|
| 
       121 
156 
     | 
    
         | 
| 
       122 
157 
     | 
    
         | 
| 
       123 
158 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 159 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       124 
160 
     | 
    
         
             
            def volga(s: float, k: float, r: float, vol: float, t: float) -> float:
         
     | 
| 
       125 
161 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       126 
162 
     | 
    
         
             
                    return 0.0
         
     | 
| 
         @@ -132,6 +168,7 @@ def volga(s: float, k: float, r: float, vol: float, t: float) -> float: 
     | 
|
| 
       132 
168 
     | 
    
         | 
| 
       133 
169 
     | 
    
         | 
| 
       134 
170 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 171 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       135 
172 
     | 
    
         
             
            def charm(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
         
     | 
| 
       136 
173 
     | 
    
         
             
                if vol <= 0 or t <= 0:
         
     | 
| 
       137 
174 
     | 
    
         
             
                    return 0.0
         
     | 
| 
         @@ -153,6 +190,7 @@ def charm(s: float, k: float, r: float, vol: float, t: float, option_type: str = 
     | 
|
| 
       153 
190 
     | 
    
         | 
| 
       154 
191 
     | 
    
         | 
| 
       155 
192 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 193 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       156 
194 
     | 
    
         
             
            def greeks(s: float, k: float, r: float, vol: float, t: float,
         
     | 
| 
       157 
195 
     | 
    
         
             
                       option_type: str = 'call') -> Dict[str, float]:
         
     | 
| 
       158 
196 
     | 
    
         
             
                return {
         
     | 
| 
         @@ -169,6 +207,7 @@ def greeks(s: float, k: float, r: float, vol: float, t: float, 
     | 
|
| 
       169 
207 
     | 
    
         | 
| 
       170 
208 
     | 
    
         | 
| 
       171 
209 
     | 
    
         
             
            @catch_exception
         
     | 
| 
      
 210 
     | 
    
         
            +
            @vectorize_inputs
         
     | 
| 
       172 
211 
     | 
    
         
             
            def iv(option_price: float, s: float, k: float, r: float, t: float,
         
     | 
| 
       173 
212 
     | 
    
         
             
                   option_type: str = 'call', precision: float = 1e-8,
         
     | 
| 
       174 
213 
     | 
    
         
             
                   max_iterations: int = 100) -> float:
         
     | 
| 
         
            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
         
     |