voly 0.0.48__tar.gz → 0.0.50__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: voly
3
- Version: 0.0.48
3
+ Version: 0.0.50
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "voly"
7
- version = "0.0.48"
7
+ version = "0.0.50"
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.48"
63
+ python_version = "0.0.50"
64
64
  warn_return_any = true
65
65
  warn_unused_configs = true
66
66
  disallow_untyped_defs = true
@@ -148,7 +148,8 @@ class VolyClient:
148
148
  return delta(s, k, r, vol, t, option_type)
149
149
 
150
150
  @staticmethod
151
- def gamma(s: float, k: float, r: float, vol: float, t: float) -> float:
151
+ def gamma(s: float, k: float, r: float, vol: float, t: float,
152
+ option_type: str = 'call') -> float:
152
153
  """
153
154
  Calculate option gamma.
154
155
 
@@ -162,10 +163,11 @@ class VolyClient:
162
163
  Returns:
163
164
  - Gamma value
164
165
  """
165
- return gamma(s, k, r, vol, t)
166
+ return gamma(s, k, r, vol, t, option_type)
166
167
 
167
168
  @staticmethod
168
- def vega(s: float, k: float, r: float, vol: float, t: float) -> float:
169
+ def vega(s: float, k: float, r: float, vol: float, t: float,
170
+ option_type: str = 'call') -> float:
169
171
  """
170
172
  Calculate option vega.
171
173
 
@@ -179,7 +181,7 @@ class VolyClient:
179
181
  Returns:
180
182
  - Vega value (for 1% change in volatility)
181
183
  """
182
- return vega(s, k, r, vol, t)
184
+ return vega(s, k, r, vol, t, option_type)
183
185
 
184
186
  @staticmethod
185
187
  def theta(s: float, k: float, r: float, vol: float, t: float,
@@ -220,7 +222,8 @@ class VolyClient:
220
222
  return rho(s, k, r, vol, t, option_type)
221
223
 
222
224
  @staticmethod
223
- def vanna(s: float, k: float, r: float, vol: float, t: float) -> float:
225
+ def vanna(s: float, k: float, r: float, vol: float, t: float,
226
+ option_type: str = 'call') -> float:
224
227
  """
225
228
  Calculate option vanna.
226
229
 
@@ -234,10 +237,11 @@ class VolyClient:
234
237
  Returns:
235
238
  - Vanna value
236
239
  """
237
- return vanna(s, k, r, vol, t)
240
+ return vanna(s, k, r, vol, t, option_type)
238
241
 
239
242
  @staticmethod
240
- def volga(s: float, k: float, r: float, vol: float, t: float) -> float:
243
+ def volga(s: float, k: float, r: float, vol: float, t: float,
244
+ option_type: str = 'call') -> float:
241
245
  """
242
246
  Calculate option volga (vomma).
243
247
 
@@ -251,7 +255,7 @@ class VolyClient:
251
255
  Returns:
252
256
  - Volga value
253
257
  """
254
- return volga(s, k, r, vol, t)
258
+ return volga(s, k, r, vol, t, option_type)
255
259
 
256
260
  @staticmethod
257
261
  def charm(s: float, k: float, r: float, vol: float, t: float,
@@ -90,21 +90,21 @@ def delta(s: float, k: float, r: float, vol: float, t: float, option_type: str =
90
90
 
91
91
  @catch_exception
92
92
  @vectorize_inputs
93
- def gamma(s: float, k: float, r: float, vol: float, t: float) -> float:
93
+ def gamma(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
94
94
  if vol <= 0 or t <= 0:
95
95
  return 0.0
96
96
 
97
- d1_val = d1(s, k, r, vol, t)
97
+ d1_val = d1(s, k, r, vol, t, option_type)
98
98
  return norm.pdf(d1_val) / (s * vol * np.sqrt(t))
99
99
 
100
100
 
101
101
  @catch_exception
102
102
  @vectorize_inputs
103
- def vega(s: float, k: float, r: float, vol: float, t: float) -> float:
103
+ def vega(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
104
104
  if vol <= 0 or t <= 0:
105
105
  return 0.0
106
106
 
107
- d1_val = d1(s, k, r, vol, t)
107
+ d1_val = d1(s, k, r, vol, t, option_type)
108
108
  return s * norm.pdf(d1_val) * np.sqrt(t) / 100 # Divided by 100 for 1% change
109
109
 
110
110
 
@@ -114,8 +114,8 @@ def theta(s: float, k: float, r: float, vol: float, t: float, option_type: str =
114
114
  if vol <= 0 or t <= 0:
115
115
  return 0.0
116
116
 
117
- d1_val = d1(s, k, r, vol, t)
118
- d2_val = d2(s, k, r, vol, t)
117
+ d1_val = d1(s, k, r, vol, t, option_type)
118
+ d2_val = d2(s, k, r, vol, t, option_type)
119
119
 
120
120
  # First part of theta (same for both call and put)
121
121
  theta_part1 = -s * norm.pdf(d1_val) * vol / (2 * np.sqrt(t))
@@ -136,7 +136,7 @@ def rho(s: float, k: float, r: float, vol: float, t: float, option_type: str = '
136
136
  if vol <= 0 or t <= 0:
137
137
  return 0.0
138
138
 
139
- d2_val = d2(s, k, r, vol, t)
139
+ d2_val = d2(s, k, r, vol, t, option_type)
140
140
 
141
141
  if option_type.lower() in ["call", "c"]:
142
142
  return k * t * np.exp(-r * t) * norm.cdf(d2_val) / 100
@@ -146,24 +146,24 @@ def rho(s: float, k: float, r: float, vol: float, t: float, option_type: str = '
146
146
 
147
147
  @catch_exception
148
148
  @vectorize_inputs
149
- def vanna(s: float, k: float, r: float, vol: float, t: float) -> float:
149
+ def vanna(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
150
150
  if vol <= 0 or t <= 0:
151
151
  return 0.0
152
152
 
153
- d1_val = d1(s, k, r, vol, t)
154
- d2_val = d2(s, k, r, vol, t)
153
+ d1_val = d1(s, k, r, vol, t, option_type)
154
+ d2_val = d2(s, k, r, vol, t, option_type)
155
155
 
156
156
  return -norm.pdf(d1_val) * d2_val / vol
157
157
 
158
158
 
159
159
  @catch_exception
160
160
  @vectorize_inputs
161
- def volga(s: float, k: float, r: float, vol: float, t: float) -> float:
161
+ def volga(s: float, k: float, r: float, vol: float, t: float, option_type: str = 'call') -> float:
162
162
  if vol <= 0 or t <= 0:
163
163
  return 0.0
164
164
 
165
- d1_val = d1(s, k, r, vol, t)
166
- d2_val = d2(s, k, r, vol, t)
165
+ d1_val = d1(s, k, r, vol, t, option_type)
166
+ d2_val = d2(s, k, r, vol, t, option_type)
167
167
 
168
168
  return s * norm.pdf(d1_val) * np.sqrt(t) * d1_val * d2_val / vol
169
169
 
@@ -174,8 +174,8 @@ def charm(s: float, k: float, r: float, vol: float, t: float, option_type: str =
174
174
  if vol <= 0 or t <= 0:
175
175
  return 0.0
176
176
 
177
- d1_val = d1(s, k, r, vol, t)
178
- d2_val = d2(s, k, r, vol, t)
177
+ d1_val = d1(s, k, r, vol, t, option_type)
178
+ d2_val = d2(s, k, r, vol, t, option_type)
179
179
 
180
180
  # First term is the same for calls and puts
181
181
  term1 = -norm.pdf(d1_val) * d1_val / (2 * t)
@@ -187,7 +187,7 @@ def charm(s: float, k: float, r: float, vol: float, t: float, option_type: str =
187
187
  term2 = r * np.exp(-r * t) * norm.cdf(-d2_val)
188
188
 
189
189
  # Return charm per day (t is in years)
190
- return (term1 + term2) / 365.0
190
+ return (term1 + term2) / 365.25
191
191
 
192
192
 
193
193
  @catch_exception
@@ -197,12 +197,12 @@ def greeks(s: float, k: float, r: float, vol: float, t: float,
197
197
  return {
198
198
  'price': bs(s, k, r, vol, t, option_type),
199
199
  'delta': delta(s, k, r, vol, t, option_type),
200
- 'gamma': gamma(s, k, r, vol, t),
201
- 'vega': vega(s, k, r, vol, t),
200
+ 'gamma': gamma(s, k, r, vol, t, option_type),
201
+ 'vega': vega(s, k, r, vol, t, option_type),
202
202
  'theta': theta(s, k, r, vol, t, option_type),
203
203
  'rho': rho(s, k, r, vol, t, option_type),
204
- 'vanna': vanna(s, k, r, vol, t),
205
- 'volga': volga(s, k, r, vol, t),
204
+ 'vanna': vanna(s, k, r, vol, t, option_type),
205
+ 'volga': volga(s, k, r, vol, t, option_type),
206
206
  'charm': charm(s, k, r, vol, t, option_type)
207
207
  }
208
208
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: voly
3
- Version: 0.0.48
3
+ Version: 0.0.50
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
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