voly 0.0.27__py3-none-any.whl → 0.0.29__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/core/charts.py CHANGED
@@ -13,6 +13,9 @@ from voly.models import SVIModel
13
13
  import plotly.graph_objects as go
14
14
  from plotly.subplots import make_subplots
15
15
  import plotly.io as pio
16
+ import plotly.express as px
17
+ from plotly.colors import hex_to_rgb, make_colorscale
18
+
16
19
 
17
20
  # Set default renderer to browser for interactive plots
18
21
  pio.renderers.default = "browser"
@@ -46,47 +49,41 @@ def plot_volatility_smile(moneyness: np.ndarray,
46
49
  y=iv * 100, # Convert to percentage
47
50
  mode='lines',
48
51
  name='Model',
49
- line=dict(color='#00FFC1', width=2)
52
+ line=dict(color='#0080FF', width=2)
50
53
  )
51
54
  )
52
55
 
53
- # Add market data if provided
54
- if market_data is not None and expiry is not None:
55
- # Filter market data for the specific expiry
56
- expiry_data = market_data[market_data['yte'] == expiry]
56
+ # Filter market data for the specific expiry
57
+ expiry_data = market_data[market_data['yte'] == expiry]
57
58
 
58
- if not expiry_data.empty:
59
- # Add bid IV
60
- fig.add_trace(
61
- go.Scatter(
62
- x=expiry_data['log_moneyness'],
63
- y=expiry_data['bid_iv'] * 100, # Convert to percentage
64
- mode='markers',
65
- name='Bid IV',
66
- marker=dict(size=8, symbol='circle', opacity=0.7)
67
- )
59
+ if not expiry_data.empty:
60
+ # Add bid IV
61
+ fig.add_trace(
62
+ go.Scatter(
63
+ x=expiry_data['log_moneyness'],
64
+ y=expiry_data['bid_iv'] * 100, # Convert to percentage
65
+ mode='markers',
66
+ name='Bid IV',
67
+ marker=dict(size=8, symbol='circle', opacity=0.7)
68
68
  )
69
+ )
69
70
 
70
- # Add ask IV
71
- fig.add_trace(
72
- go.Scatter(
73
- x=expiry_data['log_moneyness'],
74
- y=expiry_data['ask_iv'] * 100, # Convert to percentage
75
- mode='markers',
76
- name='Ask IV',
77
- marker=dict(size=8, symbol='circle', opacity=0.7)
78
- )
71
+ # Add ask IV
72
+ fig.add_trace(
73
+ go.Scatter(
74
+ x=expiry_data['log_moneyness'],
75
+ y=expiry_data['ask_iv'] * 100, # Convert to percentage
76
+ mode='markers',
77
+ name='Ask IV',
78
+ marker=dict(size=8, symbol='circle', opacity=0.7)
79
79
  )
80
+ )
80
81
 
81
- # Get maturity name and DTE for title if not provided
82
- if title is None:
83
- maturity_name = expiry_data['maturity_name'].iloc[0]
84
- dte_value = expiry_data['dte'].iloc[0]
85
- title = f'Volatility Smile for {maturity_name} (DTE: {dte_value:.1f}, YTE: {expiry:.4f})'
86
-
87
- # Use default title if not provided
88
- if title is None:
89
- title = 'Volatility Smile'
82
+ # Get maturity name and DTE for title if not provided
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})'
90
87
 
91
88
  # Update layout
92
89
  fig.update_layout(
@@ -350,19 +347,20 @@ def plot_fit_performance(fit_performance: pd.DataFrame) -> go.Figure:
350
347
 
351
348
  @catch_exception
352
349
  def plot_3d_surface(moneyness_grid: np.ndarray,
353
- iv_surface: Dict[float, np.ndarray]) -> go.Figure:
350
+ iv_surface: dict[float, np.ndarray]) -> go.Figure:
354
351
  """
355
352
  Plot 3D implied volatility surface.
356
353
 
357
354
  Parameters:
358
- - log_moneyness_grid: grid of log_moneyness values
355
+ - moneyness_grid: grid of moneyness values
359
356
  - iv_surface: Dictionary mapping expiry times to IV arrays
360
- - title: Plot title
361
357
 
362
358
  Returns:
363
359
  - Plotly figure
364
360
  """
365
-
361
+ start_color = '#0080FF'
362
+ end_color = '#004080' # Darker blue
363
+ custom_blue_scale = [[0, start_color], [1, end_color]]
366
364
  yte_values = list(iv_surface.keys())
367
365
 
368
366
  # Convert implied volatility surface to array
@@ -372,12 +370,12 @@ def plot_3d_surface(moneyness_grid: np.ndarray,
372
370
  X, Y = np.meshgrid(moneyness_grid, yte_values)
373
371
  Z = z_array * 100 # Convert to percentage
374
372
 
375
- # Create 3D surface plot
376
- fig = go.Figure(data=[go.Surface(z=Z, x=X, y=Y, colorscale='tealgrn')])
373
+ # Create 3D surface plot with custom blue colorscale
374
+ fig = go.Figure(data=[go.Surface(z=Z, x=X, y=Y, colorscale=custom_blue_scale)])
377
375
 
378
376
  # Add colorbar
379
377
  fig.update_traces(contours_z=dict(show=True, usecolormap=True,
380
- highlightcolor="limegreen", project_z=True))
378
+ highlightcolor="#0080FF", project_z=True))
381
379
 
382
380
  # Update layout
383
381
  fig.update_layout(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: voly
3
- Version: 0.0.27
3
+ Version: 0.0.29
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
@@ -4,15 +4,15 @@ voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
4
4
  voly/formulas.py,sha256=aG_HSq_a4j7TcuKiINlHSpmNdmfZa_fzYbAk8EGt954,7427
5
5
  voly/models.py,sha256=YJ12aamLz_-aOni4Qm0_XV9u4bjKK3vfJz0J2gc1h0o,3565
6
6
  voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
7
- voly/core/charts.py,sha256=aPvdv8agudljFnVZ27BURIxp3o-cvYucRtYnDUOQBUI,26809
7
+ voly/core/charts.py,sha256=RItgttSW_zDoyIbaYXX5tpVhX44GlcYyRmg36B5C4b8,26696
8
8
  voly/core/data.py,sha256=Dfk-ByHpdteUiLXr0p-wRLr3VAmdyjdDBKwjwdTgCjA,9939
9
9
  voly/core/fit.py,sha256=y0NSpNGwkm7xd_Feb6wWB3t12oXEbGVvjfXVwNV8Q-M,9971
10
10
  voly/core/interpolate.py,sha256=ztVIePJZOh-CIbn69wkh1JW2rKywNe2FEewRN0zcSAo,8185
11
11
  voly/core/rnd.py,sha256=-xBVzvM9sMIBtfOfWyBJKtiVcBShSGTNNp2PZFOD5j0,12155
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.27.dist-info/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
15
- voly-0.0.27.dist-info/METADATA,sha256=smzZW44EecovIH0hxdYNfGIvRPh4M8xmHRIFmwSrXrM,4092
16
- voly-0.0.27.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
17
- voly-0.0.27.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
18
- voly-0.0.27.dist-info/RECORD,,
14
+ voly-0.0.29.dist-info/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
15
+ voly-0.0.29.dist-info/METADATA,sha256=cP5A_arRCvbjDai5-BcPxugOfq_PTea8TYHudd-zUoY,4092
16
+ voly-0.0.29.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
17
+ voly-0.0.29.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
18
+ voly-0.0.29.dist-info/RECORD,,
File without changes
File without changes