mainsequence 2.0.0__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.
Files changed (110) hide show
  1. mainsequence/__init__.py +0 -0
  2. mainsequence/__main__.py +9 -0
  3. mainsequence/cli/__init__.py +1 -0
  4. mainsequence/cli/api.py +157 -0
  5. mainsequence/cli/cli.py +442 -0
  6. mainsequence/cli/config.py +78 -0
  7. mainsequence/cli/ssh_utils.py +126 -0
  8. mainsequence/client/__init__.py +17 -0
  9. mainsequence/client/base.py +431 -0
  10. mainsequence/client/data_sources_interfaces/__init__.py +0 -0
  11. mainsequence/client/data_sources_interfaces/duckdb.py +1468 -0
  12. mainsequence/client/data_sources_interfaces/timescale.py +479 -0
  13. mainsequence/client/models_helpers.py +113 -0
  14. mainsequence/client/models_report_studio.py +412 -0
  15. mainsequence/client/models_tdag.py +2276 -0
  16. mainsequence/client/models_vam.py +1983 -0
  17. mainsequence/client/utils.py +387 -0
  18. mainsequence/dashboards/__init__.py +0 -0
  19. mainsequence/dashboards/streamlit/__init__.py +0 -0
  20. mainsequence/dashboards/streamlit/assets/config.toml +12 -0
  21. mainsequence/dashboards/streamlit/assets/favicon.png +0 -0
  22. mainsequence/dashboards/streamlit/assets/logo.png +0 -0
  23. mainsequence/dashboards/streamlit/core/__init__.py +0 -0
  24. mainsequence/dashboards/streamlit/core/theme.py +212 -0
  25. mainsequence/dashboards/streamlit/pages/__init__.py +0 -0
  26. mainsequence/dashboards/streamlit/scaffold.py +220 -0
  27. mainsequence/instrumentation/__init__.py +7 -0
  28. mainsequence/instrumentation/utils.py +101 -0
  29. mainsequence/instruments/__init__.py +1 -0
  30. mainsequence/instruments/data_interface/__init__.py +10 -0
  31. mainsequence/instruments/data_interface/data_interface.py +361 -0
  32. mainsequence/instruments/instruments/__init__.py +3 -0
  33. mainsequence/instruments/instruments/base_instrument.py +85 -0
  34. mainsequence/instruments/instruments/bond.py +447 -0
  35. mainsequence/instruments/instruments/european_option.py +74 -0
  36. mainsequence/instruments/instruments/interest_rate_swap.py +217 -0
  37. mainsequence/instruments/instruments/json_codec.py +585 -0
  38. mainsequence/instruments/instruments/knockout_fx_option.py +146 -0
  39. mainsequence/instruments/instruments/position.py +475 -0
  40. mainsequence/instruments/instruments/ql_fields.py +239 -0
  41. mainsequence/instruments/instruments/vanilla_fx_option.py +107 -0
  42. mainsequence/instruments/pricing_models/__init__.py +0 -0
  43. mainsequence/instruments/pricing_models/black_scholes.py +49 -0
  44. mainsequence/instruments/pricing_models/bond_pricer.py +182 -0
  45. mainsequence/instruments/pricing_models/fx_option_pricer.py +90 -0
  46. mainsequence/instruments/pricing_models/indices.py +350 -0
  47. mainsequence/instruments/pricing_models/knockout_fx_pricer.py +209 -0
  48. mainsequence/instruments/pricing_models/swap_pricer.py +502 -0
  49. mainsequence/instruments/settings.py +175 -0
  50. mainsequence/instruments/utils.py +29 -0
  51. mainsequence/logconf.py +284 -0
  52. mainsequence/reportbuilder/__init__.py +0 -0
  53. mainsequence/reportbuilder/__main__.py +0 -0
  54. mainsequence/reportbuilder/examples/ms_template_report.py +706 -0
  55. mainsequence/reportbuilder/model.py +713 -0
  56. mainsequence/reportbuilder/slide_templates.py +532 -0
  57. mainsequence/tdag/__init__.py +8 -0
  58. mainsequence/tdag/__main__.py +0 -0
  59. mainsequence/tdag/config.py +129 -0
  60. mainsequence/tdag/data_nodes/__init__.py +12 -0
  61. mainsequence/tdag/data_nodes/build_operations.py +751 -0
  62. mainsequence/tdag/data_nodes/data_nodes.py +1292 -0
  63. mainsequence/tdag/data_nodes/persist_managers.py +812 -0
  64. mainsequence/tdag/data_nodes/run_operations.py +543 -0
  65. mainsequence/tdag/data_nodes/utils.py +24 -0
  66. mainsequence/tdag/future_registry.py +25 -0
  67. mainsequence/tdag/utils.py +40 -0
  68. mainsequence/virtualfundbuilder/__init__.py +45 -0
  69. mainsequence/virtualfundbuilder/__main__.py +235 -0
  70. mainsequence/virtualfundbuilder/agent_interface.py +77 -0
  71. mainsequence/virtualfundbuilder/config_handling.py +86 -0
  72. mainsequence/virtualfundbuilder/contrib/__init__.py +0 -0
  73. mainsequence/virtualfundbuilder/contrib/apps/__init__.py +8 -0
  74. mainsequence/virtualfundbuilder/contrib/apps/etf_replicator_app.py +164 -0
  75. mainsequence/virtualfundbuilder/contrib/apps/generate_report.py +292 -0
  76. mainsequence/virtualfundbuilder/contrib/apps/load_external_portfolio.py +107 -0
  77. mainsequence/virtualfundbuilder/contrib/apps/news_app.py +437 -0
  78. mainsequence/virtualfundbuilder/contrib/apps/portfolio_report_app.py +91 -0
  79. mainsequence/virtualfundbuilder/contrib/apps/portfolio_table.py +95 -0
  80. mainsequence/virtualfundbuilder/contrib/apps/run_named_portfolio.py +45 -0
  81. mainsequence/virtualfundbuilder/contrib/apps/run_portfolio.py +40 -0
  82. mainsequence/virtualfundbuilder/contrib/apps/templates/base.html +147 -0
  83. mainsequence/virtualfundbuilder/contrib/apps/templates/report.html +77 -0
  84. mainsequence/virtualfundbuilder/contrib/data_nodes/__init__.py +5 -0
  85. mainsequence/virtualfundbuilder/contrib/data_nodes/external_weights.py +61 -0
  86. mainsequence/virtualfundbuilder/contrib/data_nodes/intraday_trend.py +149 -0
  87. mainsequence/virtualfundbuilder/contrib/data_nodes/market_cap.py +310 -0
  88. mainsequence/virtualfundbuilder/contrib/data_nodes/mock_signal.py +78 -0
  89. mainsequence/virtualfundbuilder/contrib/data_nodes/portfolio_replicator.py +269 -0
  90. mainsequence/virtualfundbuilder/contrib/prices/__init__.py +1 -0
  91. mainsequence/virtualfundbuilder/contrib/prices/data_nodes.py +810 -0
  92. mainsequence/virtualfundbuilder/contrib/prices/utils.py +11 -0
  93. mainsequence/virtualfundbuilder/contrib/rebalance_strategies/__init__.py +1 -0
  94. mainsequence/virtualfundbuilder/contrib/rebalance_strategies/rebalance_strategies.py +313 -0
  95. mainsequence/virtualfundbuilder/data_nodes.py +637 -0
  96. mainsequence/virtualfundbuilder/enums.py +23 -0
  97. mainsequence/virtualfundbuilder/models.py +282 -0
  98. mainsequence/virtualfundbuilder/notebook_handling.py +42 -0
  99. mainsequence/virtualfundbuilder/portfolio_interface.py +272 -0
  100. mainsequence/virtualfundbuilder/resource_factory/__init__.py +0 -0
  101. mainsequence/virtualfundbuilder/resource_factory/app_factory.py +170 -0
  102. mainsequence/virtualfundbuilder/resource_factory/base_factory.py +238 -0
  103. mainsequence/virtualfundbuilder/resource_factory/rebalance_factory.py +101 -0
  104. mainsequence/virtualfundbuilder/resource_factory/signal_factory.py +183 -0
  105. mainsequence/virtualfundbuilder/utils.py +381 -0
  106. mainsequence-2.0.0.dist-info/METADATA +105 -0
  107. mainsequence-2.0.0.dist-info/RECORD +110 -0
  108. mainsequence-2.0.0.dist-info/WHEEL +5 -0
  109. mainsequence-2.0.0.dist-info/licenses/LICENSE +40 -0
  110. mainsequence-2.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,706 @@
1
+ from typing import Any, Optional, List, Union, Dict
2
+ import copy
3
+
4
+ from pathlib import Path
5
+
6
+ from mainsequence.reportbuilder.model import (
7
+ Presentation,
8
+ Slide,
9
+ GridLayout,
10
+ GridCell,
11
+ TextElement,
12
+ ImageElement,
13
+ HtmlElement,
14
+ FontWeight,
15
+ HorizontalAlign,
16
+ VerticalAlign,
17
+ Size,
18
+ StyleSettings,
19
+ ThemeMode, TextH1, TextH2,
20
+ )
21
+ from mainsequence.reportbuilder.slide_templates import (
22
+ generic_plotly_table,
23
+ generic_plotly_pie_chart,
24
+ generic_plotly_bar_chart,
25
+ generic_plotly_grouped_bar_chart
26
+ )
27
+
28
+ styles = StyleSettings(mode=ThemeMode.light)
29
+ styles.logo_url = "https://cdn.prod.website-files.com/67d166ea95c73519badbdabd/67d166ea95c73519badbdc60_Asset%25202%25404x-8-p-800.png"
30
+
31
+ report_main_color = "#003049" # mainsequence.reportbuilder.model.main_sequence_blue
32
+ report_text_color_dark = "#333333"
33
+ report_text_color_light_gray = "#555555"
34
+
35
+ fixed_income_local_headers = ["INSTRUMENT", "UNITS", "PRICE", "AMOUNT", "% TOTAL", "DURATION", "YIELD", "DxV"]
36
+ fixed_income_local_rows = [
37
+ ["Alpha Bond 2025", "350,000", "$99.50", "$34,825,000.00", "7.50%", "0.25", "9.05%", "90"],
38
+ ["Beta Note 2026", "160,000", "$99.80", "$15,968,000.00", "3.60%", "1.30", "9.15%", "530"],
39
+ ["Gamma Security 2026", "250,000", "$99.90", "$24,975,000.00", "5.60%", "1.50", "9.20%", "600"],
40
+ ["Delta Issue 2027", "245,000", "$100.10", "$24,524,500.00", "5.40%", "1.60", "9.25%", "630"],
41
+ ["Epsilon Paper 2026", "200,000", "$98.50", "$19,700,000.00", "4.40%", "0.80", "8.30%", "300"],
42
+ ["Zeta Bond 2029", "170,000", "$102.50", "$17,425,000.00", "3.90%", "3.30", "8.60%", "1,500"],
43
+ ["Eta Security 2030", "180,000", "$100.00", "$18,000,000.00", "4.00%", "3.80", "8.80%", "1,700"],
44
+ ["Theta Note 2034", "110,000", "$93.00", "$10,230,000.00", "2.30%", "6.30", "9.30%", "3,500"],
45
+ ["Iota UDI 2028", "40,000", "$98.00", "$33,600,000.00", "7.90%", "3.20", "4.90%", "1,300"],
46
+ ["Kappa C-Bill 2026A", "2,500,000", "$9.20", "$23,000,000.00", "5.10%", "0.85", "8.40%", "340"],
47
+ ["Lambda C-Bill 2026B", "3,300,000", "$8.80", "$29,040,000.00", "6.70%", "1.25", "8.50%", "520"],
48
+ ["TOTAL", "", "", "$251,287,500.00", "56.70%", "1.60", "8.55%", "480"]
49
+ ]
50
+
51
+ fixed_income_usd_headers = ["INSTRUMENT", "UNITS", "PRICE", "AMOUNT", "% TOTAL", "DURATION", "YIELD", "DxV"]
52
+ fixed_income_usd_rows = [
53
+ ["Global Note A", "16,000", "$2,900.00", "$46,400,000.00", "10.00%", "8.50", "4.30%", "3,100"],
54
+ ["International Bond X", "40,000", "$2,200.00", "$88,000,000.00", "20.00%", "1.90", "3.90%", "700"],
55
+ ["TOTAL", "", "", "$134,400,000.00", "30.00%", "4.10", "4.00%", "1,500"]
56
+ ]
57
+
58
+ liquidity_headers = ["INSTRUMENT", "UNITS", "PRICE", "AMOUNT", "% TOTAL", "DURATION", "YIELD", "DxV"]
59
+ liquidity_rows = [
60
+ ["Repo Agreement", "", "", "$55,000,000.00", "12.50%", "0.01", "9.50%", "5"],
61
+ ["Cash Equiv. (Local)", "", "", "$150.00", "0.00%", "", "", ""],
62
+ ["Cash Equiv. (USD)", "50,000", "", "$1,000,000.00", "0.20%", "", "", ""],
63
+ ["TOTAL", "", "", "$56,000,150.00", "12.70%", "", "", ""]
64
+ ]
65
+
66
+
67
+ def title_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
68
+ cover_slide_main_title_text = "Strategic Portfolio Insights"
69
+ cover_slide_subtitle_text = f"Monthly Review & Performance Outlook"
70
+ cover_slide_tagline_text = "Navigating Your Financial Future with Precision"
71
+ enlarged_logo_height_str = "75px"
72
+
73
+ el_main_title = TextElement(
74
+ text=cover_slide_main_title_text,
75
+ element_type="h1",
76
+ font_weight=FontWeight.bold,
77
+ h_align=HorizontalAlign.left,
78
+ color=slide_styles.heading_color # Use theme color
79
+ )
80
+ el_subtitle = TextElement(
81
+ text=cover_slide_subtitle_text,
82
+ element_type="h2",
83
+ h_align=HorizontalAlign.left,
84
+ color=slide_styles.heading_color
85
+ )
86
+ el_logo = ImageElement(
87
+ src=slide_styles.logo_url,
88
+ alt="Main Sequence Logo",
89
+ size=Size(height=enlarged_logo_height_str, width="auto")
90
+ )
91
+ el_tagline = TextElement(
92
+ text=cover_slide_tagline_text,
93
+ element_type="h5",
94
+ h_align=HorizontalAlign.left,
95
+ color=slide_styles.paragraph_color
96
+ )
97
+
98
+ # Use cover_slide_element_left_indent from StyleSettings if available, else default
99
+ left_indent = getattr(slide_styles, 'cover_slide_element_left_indent', "8%")
100
+
101
+ cover_layout = GridLayout(
102
+ row_definitions=["20%", "auto", "auto", "auto", "auto", "1fr"],
103
+ col_definitions=[left_indent, "auto", "1fr"],
104
+ gap=12,
105
+ cells=[
106
+ GridCell(row=2, col=2, element=el_main_title, justify_self=HorizontalAlign.left, align_self=VerticalAlign.bottom),
107
+ GridCell(row=3, col=2, element=el_subtitle, justify_self=HorizontalAlign.left, align_self=VerticalAlign.top),
108
+ GridCell(row=4, col=2, element=el_logo, justify_self=HorizontalAlign.left, align_self=VerticalAlign.center, padding="20px 0 0 0"),
109
+ GridCell(row=5, col=2, element=el_tagline, justify_self=HorizontalAlign.left, align_self=VerticalAlign.top)
110
+ ],
111
+ width="100%",
112
+ height="100%"
113
+ )
114
+ return Slide(
115
+ title="Main Cover",
116
+ layout=cover_layout,
117
+ footer_info=footer_text,
118
+ style_theme=slide_styles
119
+ )
120
+
121
+
122
+ def portfolio_detail_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
123
+ shared_column_widths = [1.8, 1, 1, 1.5, 0.7, 0.8, 0.8, 0.7]
124
+ shared_cell_align: Union[str, List[str]] = ['left', 'right', 'right', 'right', 'right', 'right', 'right', 'right']
125
+ table_figure_width = 900
126
+
127
+ # Use paragraph font family for charts from the theme
128
+ chart_font_family = slide_styles.font_family_paragraphs
129
+ chart_label_font_size = slide_styles.chart_label_font_size
130
+
131
+ fi_local_html = generic_plotly_table(
132
+ headers=fixed_income_local_headers, rows=fixed_income_local_rows,
133
+ column_widths=shared_column_widths, cell_align=shared_cell_align, fig_width=table_figure_width,
134
+ header_font_dict=dict(color=slide_styles.background_color, size=10, family=chart_font_family),
135
+ cell_font_dict=dict(size=chart_label_font_size, family=chart_font_family, color=slide_styles.paragraph_color),
136
+ theme_mode=slide_styles.mode
137
+ )
138
+ fi_usd_html = generic_plotly_table(
139
+ headers=fixed_income_usd_headers, rows=fixed_income_usd_rows,
140
+ column_widths=shared_column_widths, cell_align=shared_cell_align, fig_width=table_figure_width,
141
+ header_font_dict=dict(color=slide_styles.background_color, size=10, family=chart_font_family),
142
+ cell_font_dict=dict(size=chart_label_font_size, family=chart_font_family, color=slide_styles.paragraph_color),
143
+ theme_mode=slide_styles.mode
144
+ )
145
+ liquidity_html = generic_plotly_table(
146
+ headers=liquidity_headers, rows=liquidity_rows,
147
+ column_widths=shared_column_widths, cell_align=shared_cell_align, fig_width=table_figure_width,
148
+ header_font_dict=dict(color=slide_styles.background_color, size=10, family=chart_font_family),
149
+ cell_font_dict=dict(size=chart_label_font_size, family=chart_font_family, color=slide_styles.paragraph_color),
150
+ theme_mode=slide_styles.mode
151
+ )
152
+
153
+ total_general_rows = [["TOTAL", "", "", "$441,687,650.00", "100.00%", "", "", ""]]
154
+ total_table_html = generic_plotly_table(
155
+ headers=liquidity_headers, rows=total_general_rows, fig_width=table_figure_width,
156
+ column_widths=shared_column_widths,
157
+ cell_align=['left', 'right', 'right', 'right', 'right', 'right', 'right', 'right'],
158
+ cell_fill_color='rgba(0,0,0,0)', line_color='rgba(0,0,0,0)',
159
+ header_fill_color='rgba(0,0,0,0)', # header_font_color default will make it invisible too
160
+ margin_dict=dict(l=0, r=0, t=5, b=0),
161
+ cell_font_dict=dict(size=12, family=chart_font_family, color=slide_styles.paragraph_color), # Ensure total row text is visible
162
+ theme_mode=slide_styles.mode
163
+ )
164
+
165
+ slide_layout = GridLayout(
166
+ row_definitions=["auto", "auto", "auto", "auto", "auto"],
167
+ col_definitions=[slide_styles.title_column_width, "1fr"],
168
+ gap=0,
169
+ cells=[
170
+ GridCell(row=1, col=1, col_span=2, element=TextElement(
171
+ text="Portfolio", element_type="h3", font_weight=FontWeight.bold,
172
+ h_align=HorizontalAlign.left, color=report_main_color
173
+ ), padding="0 0 3px 0"),
174
+ GridCell(row=2, col=1, element=TextElement(
175
+ text="Fixed Income (Local Currency)", element_type="p", font_weight=FontWeight.bold,
176
+ color=report_main_color, h_align=HorizontalAlign.left, v_align=VerticalAlign.center
177
+ ), padding="2px 10px 2px 0", align_self="start"),
178
+ GridCell(row=2, col=2, element=HtmlElement(html=fi_local_html), padding="2px 0 2px 0"),
179
+ GridCell(row=3, col=1, element=TextElement(
180
+ text="Fixed Income (USD)", element_type="p", font_weight=FontWeight.bold,
181
+ color=report_main_color, h_align=HorizontalAlign.left, v_align=VerticalAlign.center
182
+ ), padding="2px 10px 2px 0", align_self="start"),
183
+ GridCell(row=3, col=2, element=HtmlElement(html=fi_usd_html), padding="2px 0 2px 0"),
184
+ GridCell(row=4, col=1, element=TextElement(
185
+ text="Liquidity", element_type="p", font_weight=FontWeight.bold,
186
+ color=report_main_color, h_align=HorizontalAlign.left, v_align=VerticalAlign.center
187
+ ), padding="2px 10px 2px 0", align_self="start"),
188
+ GridCell(row=4, col=2, element=HtmlElement(html=liquidity_html), padding="2px 0 2px 0"),
189
+ GridCell(row=5, col=2, element=HtmlElement(html=total_table_html), padding="2px 0 2px 0"),
190
+ ]
191
+ )
192
+ return Slide(
193
+ title="Portfolio Detail",
194
+ layout=slide_layout,
195
+ footer_info=footer_text,
196
+ style_theme=slide_styles
197
+ )
198
+
199
+
200
+ def pie_chart_bars_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
201
+ pie_chart_slice_colors = slide_styles.chart_palette_categorical[:3] # Use theme palette
202
+ chart_font_family = slide_styles.font_family_paragraphs
203
+ chart_label_font_size = slide_styles.chart_label_font_size
204
+
205
+ asset_table_headers_raw = ["ASSET CLASS", "%"]
206
+ asset_table_rows_data = [["Domestic Equities", "57%"], ["International Bonds", "30%"], ["Cash & Equivalents", "13%"]]
207
+ asset_class_table_html = generic_plotly_table(
208
+ headers=asset_table_headers_raw, rows=asset_table_rows_data, table_height=125, fig_width=300,
209
+ column_widths=[0.3, 0.2],
210
+ header_font_dict=dict(color=slide_styles.background_color, size=10, family=chart_font_family),
211
+ cell_font_dict=dict(size=chart_label_font_size, family=chart_font_family, color=slide_styles.paragraph_color),
212
+ cell_align=['left', 'right'], theme_mode=slide_styles.mode
213
+ )
214
+ asset_class_table_el = HtmlElement(html=asset_class_table_html)
215
+
216
+ asset_pie_labels = ["Domestic Equities", "Cash & Equivalents", "International Bonds"]
217
+ asset_pie_values = [57, 13, 30]
218
+ asset_pie_html = generic_plotly_pie_chart(
219
+ labels=asset_pie_labels, values=asset_pie_values, colors=pie_chart_slice_colors, height=400, width=430,
220
+ textinfo='percent',
221
+ legend_dict=dict(font=dict(size=chart_label_font_size, family=chart_font_family),
222
+ orientation="h", yanchor="top", y=-0.1, xanchor="center", x=0.5, bgcolor='rgba(0,0,0,0)'),
223
+ font_dict=dict(family=chart_font_family, color=slide_styles.paragraph_color), theme_mode=slide_styles.mode
224
+ )
225
+ asset_pie_el = HtmlElement(html=asset_pie_html)
226
+
227
+ duration_bar_labels = [">7 Years", "3-7 Years", "2-3 Years", "1-2 Years", "0-1 Years", "Short-Term/Cash"]
228
+ duration_bar_values = [10.05, 12.07, 0.20, 41.52, 12.16, 12.76]
229
+ max_val = max(duration_bar_values) if duration_bar_values else 1
230
+ custom_xaxis_bar_dict = dict(
231
+ showgrid=False, zeroline=False, showline=False, showticklabels=True, ticksuffix='%', side='bottom',
232
+ tickfont=dict(size=chart_label_font_size, color=report_text_color_dark, family=chart_font_family),
233
+ range=[0, max_val * 1.115]
234
+ )
235
+ custom_yaxis_bar_dict = dict(
236
+ showgrid=False, zeroline=False, showline=False,
237
+ tickfont=dict(size=chart_label_font_size, color=report_text_color_dark, family=chart_font_family),
238
+ autorange="reversed"
239
+ )
240
+ duration_bar_html = generic_plotly_bar_chart(
241
+ y_values=duration_bar_labels, x_values=duration_bar_values, orientation='h',
242
+ bar_color=report_main_color, width=450, height=450,
243
+ xaxis_dict=custom_xaxis_bar_dict, yaxis_dict=custom_yaxis_bar_dict,
244
+ font_dict=dict(family=chart_font_family, color=slide_styles.paragraph_color),
245
+ textfont_dict=dict(size=chart_label_font_size, family=chart_font_family, color=slide_styles.paragraph_color),
246
+ theme_mode=slide_styles.mode
247
+ )
248
+ duration_bar_el = HtmlElement(html=duration_bar_html)
249
+
250
+ slide_layout = GridLayout(
251
+ row_definitions=["auto", "auto", "1fr"], col_definitions=["1fr", "1fr"], gap=10,
252
+ cells=[
253
+ GridCell(row=1, col=1, element=TextElement(
254
+ text=f"Asset Allocation", element_type="p", font_weight=FontWeight.bold,
255
+ color=report_main_color, h_align=HorizontalAlign.left
256
+ ), align_self=VerticalAlign.bottom, padding="0 0 2px 0"),
257
+ GridCell(row=2, col=1, element=asset_class_table_el, align_self=VerticalAlign.top, justify_self=HorizontalAlign.center, padding="5px 0 0 0"),
258
+ GridCell(row=3, col=1, element=asset_pie_el, align_self=VerticalAlign.center, justify_self=HorizontalAlign.center, padding="5px 0 0 0"),
259
+ GridCell(row=1, col=2, element=TextElement(
260
+ text="Duration Breakdown", element_type="p", font_weight=FontWeight.bold,
261
+ color=report_main_color, h_align=HorizontalAlign.left
262
+ ), align_self=VerticalAlign.bottom, padding="0 0 2px 0"),
263
+ GridCell(row=2, col=2, row_span=2, element=duration_bar_el, align_self=VerticalAlign.center, justify_self=HorizontalAlign.left, padding="5px 0 0 0")
264
+ ]
265
+ )
266
+ return Slide(
267
+ title="Portfolio Snapshot", layout=slide_layout, footer_info=footer_text, style_theme=slide_styles
268
+ )
269
+
270
+
271
+ def generic_table_and_grouped_bar_chart_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
272
+ slide_main_title_text = "Component Analysis: Multi-Series Data"
273
+ chart_font_family = slide_styles.font_family_paragraphs
274
+ chart_label_font_size = slide_styles.chart_label_font_size
275
+
276
+ table_headers = ["Type", "Value Set 1", "Value Set 2", "Difference (VS1-VS2)"]
277
+ raw_table_rows_data = [
278
+ ["Alpha Group", 0.60, 0.40], ["Beta Group", 0.45, 0.50], ["Gamma Group", 0.70, 0.55],
279
+ ["Delta Group", 0.25, 0.25], ["Epsilon Group", 0.50, 0.30], ["Zeta Group", 0.10, 0.15],
280
+ ]
281
+ table_rows_processed, total_vs1, total_vs2, total_diff = [], 0, 0, 0
282
+ for row_data in raw_table_rows_data:
283
+ category, vs1, vs2 = row_data;
284
+ diff = round(vs1 - vs2, 2)
285
+ table_rows_processed.append([category, f"{vs1:.2f}", f"{vs2:.2f}", f"{diff:.2f}"])
286
+ total_vs1 += vs1;
287
+ total_vs2 += vs2;
288
+ total_diff += diff
289
+ table_rows_processed.append(["<b>TOTAL</b>", f"<b>{total_vs1:.2f}</b>", f"<b>{total_vs2:.2f}</b>", f"<b>{total_diff:.2f}</b>"])
290
+
291
+ generic_table_html = generic_plotly_table(
292
+ headers=table_headers, rows=table_rows_processed, column_widths=[0.7, 0.3, 0.3, 0.3],
293
+ cell_align=['left', 'right', 'right', 'right'],
294
+ header_font_dict=dict(color=slide_styles.background_color, size=10, family=chart_font_family),
295
+ cell_font_dict=dict(size=chart_label_font_size, family=chart_font_family, color=slide_styles.paragraph_color),
296
+ fig_width=700, theme_mode=slide_styles.mode
297
+ )
298
+
299
+ chart_categories = [f"Point {i + 1}" for i in range(11)]
300
+ series_a_values = [0.50, 0.45, 0.60, 0.30, 0.75, 0.20, 0.55, 0.40, 0.65, 0.35, 0.70]
301
+ series_b_values = [0.40, 0.50, 0.55, 0.35, 0.60, 0.25, 0.60, 0.30, 0.70, 0.25, 0.65]
302
+ series_data_for_chart = [
303
+ {"name": "Data Series A", "y_values": series_a_values, "color": report_main_color},
304
+ {"name": "Data Series B", "y_values": series_b_values, "color": 'rgb(200,200,200)'},
305
+ {"name": "Difference (A-B)", "y_values": [round(a - b, 2) for a, b in zip(series_a_values, series_b_values)], "color": 'rgb(160,120,70)'}
306
+ ]
307
+ custom_legend = dict(orientation="h", yanchor="top", y=-0.15, xanchor="center", x=0.5,
308
+ font=dict(size=chart_label_font_size, family=chart_font_family), bgcolor='rgba(0,0,0,0)')
309
+ generic_bar_chart_html = generic_plotly_grouped_bar_chart(
310
+ x_values=chart_categories, series_data=series_data_for_chart, chart_title="",
311
+ height=380, width=800, y_axis_tick_format=".2f", xaxis_tickangle=-45,
312
+ legend_dict=custom_legend, margin_dict=dict(l=30, r=20, t=10, b=120), theme_mode=slide_styles.mode
313
+ )
314
+
315
+ slide_layout = GridLayout(
316
+ row_definitions=["auto", "auto", "auto"], col_definitions=["1fr"], gap=10,
317
+ cells=[
318
+ GridCell(row=1, col=1, element=TextElement(
319
+ text=slide_main_title_text, element_type="h5", font_weight=FontWeight.bold,
320
+ color=report_main_color, h_align=HorizontalAlign.center
321
+ ), padding="0 0 2px 0"),
322
+ GridCell(row=2, col=1, element=HtmlElement(html=generic_table_html), justify_self=HorizontalAlign.center, align_self=VerticalAlign.center),
323
+ GridCell(row=3, col=1, element=HtmlElement(html=generic_bar_chart_html), justify_self=HorizontalAlign.center, padding="5px 0 0 0")
324
+ ]
325
+ )
326
+ return Slide(
327
+ title="Generic Grouped Bar Chart and Table", layout=slide_layout, footer_info=footer_text, style_theme=slide_styles
328
+ )
329
+
330
+
331
+ def portfolio_performance_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
332
+ portfolio_bar_color = report_main_color
333
+ benchmark_bar_color = "#CDA434"
334
+
335
+ monthly_categories = ["JAN", "FEB", "MAR", "APR"]
336
+ monthly_series_data = [
337
+ {"name": "Portfolio", "y_values": [0.83, 1.13, 1.72, 1.08], "color": portfolio_bar_color},
338
+ {"name": "Benchmark", "y_values": [1.38, 1.47, 1.31, 1.02], "color": benchmark_bar_color}
339
+ ]
340
+ monthly_chart_html = generic_plotly_grouped_bar_chart(
341
+ x_values=monthly_categories, series_data=monthly_series_data, chart_title="Monthly Performance (LCY)",
342
+ height=280, width=750, y_axis_tick_format=".2f", bar_text_template="%{y:.2f}%",
343
+ legend_dict=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
344
+ margin_dict=dict(l=40, r=20, t=50, b=40), theme_mode=slide_styles.mode
345
+ )
346
+
347
+ annual_categories = ["2023", "2024"]
348
+ annual_series_data = [
349
+ {"name": "Portfolio", "y_values": [4.84, 11.45], "color": portfolio_bar_color},
350
+ {"name": "Benchmark", "y_values": [5.28, 9.91], "color": benchmark_bar_color}
351
+ ]
352
+ annual_chart_html = generic_plotly_grouped_bar_chart(
353
+ x_values=annual_categories, series_data=annual_series_data, chart_title="Annual Performance (LCY)",
354
+ height=240, width=750, y_axis_tick_format=".2f", bar_text_template="%{y:.2f}%",
355
+ legend_dict=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
356
+ margin_dict=dict(l=40, r=20, t=50, b=40), theme_mode=slide_styles.mode
357
+ )
358
+
359
+ slide_layout = GridLayout(
360
+ row_definitions=["auto", "auto", "auto"], col_definitions=["1fr"], gap=10,
361
+ cells=[
362
+ GridCell(row=1, col=1, element=TextElement(
363
+ text="Portfolio Performance in Local Currency", element_type="h4", font_weight=FontWeight.bold,
364
+ color=report_main_color, h_align=HorizontalAlign.left
365
+ ), padding="0 0 5px 0"),
366
+ GridCell(row=2, col=1, element=HtmlElement(html=monthly_chart_html), justify_self=HorizontalAlign.center),
367
+ GridCell(row=3, col=1, element=HtmlElement(html=annual_chart_html), justify_self=HorizontalAlign.center),
368
+ ]
369
+ )
370
+ return Slide(
371
+ title="Financial Performance Summary", layout=slide_layout, footer_info=footer_text, style_theme=slide_styles
372
+ )
373
+
374
+
375
+ def rate_sensitivity_analysis_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
376
+ slide_main_title_text = "Rate Sensitivity Analysis: USD Portfolio"
377
+ chart_font_family = slide_styles.font_family_paragraphs
378
+ chart_label_font_size = slide_styles.chart_label_font_size
379
+
380
+ table1_headers, table1_rows = ["Factor", "Portfolio", "Benchmark", "Active"], [["Factor A", "60%", "100%", "-40%"], ["Factor B", "30%", "0%", "30%"],
381
+ ["Factor C", "10%", "0%", "10%"]]
382
+ table1_html = generic_plotly_table(
383
+ headers=table1_headers, rows=table1_rows, fig_width=350, table_height=120, column_widths=[0.8, 0.5, 0.5, 0.5],
384
+ cell_align=['left', 'center', 'center', 'center'],
385
+ header_font_dict=dict(color=slide_styles.background_color, size=10, family=chart_font_family),
386
+ cell_font_dict=dict(size=chart_label_font_size, family=chart_font_family, color=slide_styles.paragraph_color),
387
+ header_fill_color=report_main_color, cell_fill_color='rgb(245,245,245)', line_color='rgb(220,220,220)',
388
+ theme_mode=slide_styles.mode
389
+ )
390
+ table2_headers, table2_rows = ["Factor", "Portfolio", "Benchmark", "Active"], [["Factor A", "1.30", "1.90", "-0.60"], ["Factor B", "2.80", "-", "2.80"],
391
+ ["Factor C", "-", "-", "-"], ["Total", "4.10", "1.90", "2.20"]]
392
+ table2_html = generic_plotly_table(
393
+ headers=table2_headers, rows=table2_rows, fig_width=350, table_height=145, column_widths=[0.8, 0.5, 0.5, 0.5],
394
+ cell_align=['left', 'right', 'right', 'right'],
395
+ header_font_dict=dict(color=slide_styles.background_color, size=10, family=chart_font_family),
396
+ cell_font_dict=dict(size=chart_label_font_size, family=chart_font_family, color=slide_styles.paragraph_color),
397
+ header_fill_color=report_main_color, cell_fill_color='rgb(245,245,245)', line_color='rgb(220,220,220)',
398
+ theme_mode=slide_styles.mode
399
+ )
400
+ bar_chart_categories = ["Factor A", "Factor B"]
401
+ bar_chart_series_data = [
402
+ {"name": "Portfolio", "y_values": [1.30, 2.80], "color": report_main_color},
403
+ {"name": "Benchmark", "y_values": [1.90, 0.00], "color": 'rgb(173, 216, 230)'},
404
+ {"name": "Active", "y_values": [-0.60, 2.80], "color": 'rgb(205, 164, 52)'}
405
+ ]
406
+ bar_chart_html = generic_plotly_grouped_bar_chart(
407
+ x_values=bar_chart_categories, series_data=bar_chart_series_data, chart_title="", height=350, width=720,
408
+ y_axis_tick_format=".2f", bar_text_template=None,
409
+ legend_dict=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="center", x=0.5,
410
+ font=dict(size=chart_label_font_size, family=chart_font_family), bgcolor='rgba(0,0,0,0)'),
411
+ margin_dict=dict(l=40, r=20, t=30, b=40), theme_mode=slide_styles.mode
412
+ )
413
+ slide_layout = GridLayout(
414
+ row_definitions=["auto", "auto", "1fr"], col_definitions=["1fr", "1fr"], gap=15,
415
+ cells=[
416
+ GridCell(row=1, col=1, col_span=2, element=TextElement(
417
+ text=slide_main_title_text, element_type="h4", font_weight=FontWeight.bold,
418
+ color=report_main_color, h_align=HorizontalAlign.left
419
+ ), padding="0 0 10px 0"),
420
+ GridCell(row=2, col=1, element=HtmlElement(html=table1_html), justify_self=HorizontalAlign.center, align_self=VerticalAlign.top),
421
+ GridCell(row=2, col=2, element=HtmlElement(html=table2_html), justify_self=HorizontalAlign.center, align_self=VerticalAlign.top),
422
+ GridCell(row=3, col=1, col_span=2, element=HtmlElement(html=bar_chart_html), justify_self=HorizontalAlign.center, align_self=VerticalAlign.center,
423
+ padding="20px 0 0 0")
424
+ ]
425
+ )
426
+ return Slide(
427
+ title="Rate Sensitivity Analysis", layout=slide_layout, footer_info=footer_text, style_theme=slide_styles
428
+ )
429
+
430
+
431
+ def issuer_performance_table_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
432
+ slide_content_main_title = "Performance Analysis: Key Segments"
433
+ table_super_header1_text, table_super_header2_text = "PORTFOLIOS", "SUB-CATEGORY DETAILS"
434
+ table_headers = ["Category", "Weight (%)", "Return (%)", "Impact (%)"]
435
+ table_rows_data = [["Alpha Product Series 1", "-67.0%", "0.69%", "0.09%"], ["Beta Service Line 2", "66.3%", "0.92%", "0.30%"],
436
+ ["Gamma Component Type 3", "0.7%", "-4.05%", "-0.03%"]]
437
+ chart_font_family = slide_styles.font_family_paragraphs
438
+ chart_label_font_size = slide_styles.chart_label_font_size
439
+
440
+ issuer_table_html = generic_plotly_table(
441
+ headers=table_headers, rows=table_rows_data, fig_width=800, table_height=150, column_widths=[2, 1, 1, 1],
442
+ cell_align=['left', 'right', 'right', 'right'], header_align=['center', 'center', 'center', 'center'],
443
+ header_font_dict=dict(color=slide_styles.background_color, size=chart_label_font_size + 1, family=chart_font_family),
444
+ cell_font_dict=dict(size=chart_label_font_size, family=chart_font_family, color=report_text_color_dark),
445
+ header_fill_color=report_main_color, cell_fill_color='white', line_color='rgb(150,150,150)',
446
+ header_height=25, cell_height=25, margin_dict=dict(l=5, r=5, t=5, b=5), theme_mode=slide_styles.mode
447
+ )
448
+ slide_layout = GridLayout(
449
+ row_definitions=["auto", "auto", "auto", "auto", "1fr"], col_definitions=["1fr"], gap=0,
450
+ cells=[
451
+ GridCell(row=1, col=1, element=TextElement(
452
+ text=slide_content_main_title, element_type="h4", font_weight=FontWeight.bold,
453
+ color=report_main_color, h_align=HorizontalAlign.left
454
+ ), padding="0 0 20px 0"),
455
+ GridCell(row=2, col=1, element=TextElement(
456
+ text=table_super_header1_text, element_type="p", font_weight=FontWeight.bold,
457
+ color=report_text_color_dark, h_align=HorizontalAlign.center
458
+ ), padding="5px 0 0 0", background_color="white"),
459
+ GridCell(row=3, col=1, element=TextElement(
460
+ text=table_super_header2_text, element_type="p", font_weight=FontWeight.bold,
461
+ color=report_text_color_dark, h_align=HorizontalAlign.center
462
+ ), padding="0 0 0 0", background_color="white"),
463
+ GridCell(row=4, col=1, element=HtmlElement(html=issuer_table_html), justify_self=HorizontalAlign.center, align_self=VerticalAlign.top,
464
+ padding="0 0 0 0")
465
+ ]
466
+ )
467
+ return Slide(
468
+ title="Category Performance Summary", layout=slide_layout, footer_info=footer_text, style_theme=slide_styles
469
+ )
470
+
471
+
472
+ def comparative_performance_charts_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
473
+ slide_content_main_title = "Overall Portfolio Performance: USD"
474
+ portfolio_color, benchmark_color = report_main_color, 'rgb(189, 149, 58)'
475
+ chart_label_font_size = slide_styles.chart_label_font_size
476
+ chart_font_family = slide_styles.font_family_paragraphs
477
+
478
+ monthly_chart_title, monthly_categories = "Monthly USD Returns", ["Jan", "Feb", "Mar", "Apr"]
479
+ monthly_series_data = [
480
+ {"name": "Portfolio", "y_values": [0.2, 1.62, 0.6, 1.31], "color": portfolio_color},
481
+ {"name": "Benchmark", "y_values": [0.1, 0.32, 0.89, 0.12], "color": benchmark_color}
482
+ ]
483
+ monthly_legend_config = dict(orientation="v", yanchor="top", y=1, xanchor="left", x=1.01,
484
+ font=dict(size=chart_label_font_size - 1, family=chart_font_family), bgcolor='rgba(0,0,0,0)')
485
+ monthly_chart_html = generic_plotly_grouped_bar_chart(
486
+ x_values=monthly_categories, series_data=monthly_series_data, chart_title=monthly_chart_title,
487
+ height=300, width=700, y_axis_tick_format=".2f", bar_text_template="%{y:.2f}%", bar_text_position="outside",
488
+ legend_dict=monthly_legend_config, margin_dict=dict(l=50, r=100, t=50, b=40), title_x_position=0.5,
489
+ theme_mode=slide_styles.mode
490
+ )
491
+ annual_chart_title, annual_categories = "Annual Returns", ["Prior Year", "Current Year"]
492
+ annual_series_data = [
493
+ {"name": "Portfolio", "y_values": [2.49, 5.78], "color": portfolio_color},
494
+ {"name": "Benchmark", "y_values": [3.30, 5.18], "color": benchmark_color}
495
+ ]
496
+ annual_legend_config = dict(orientation="v", yanchor="top", y=1, xanchor="left", x=1.01,
497
+ font=dict(size=chart_label_font_size - 1, family=chart_font_family), bgcolor='rgba(0,0,0,0)')
498
+ annual_chart_html = generic_plotly_grouped_bar_chart(
499
+ x_values=annual_categories, series_data=annual_series_data, chart_title=annual_chart_title,
500
+ height=330, width=700, y_axis_tick_format=".2f", bar_text_template="%{y:.2f}%", bar_text_position="outside",
501
+ legend_dict=annual_legend_config, margin_dict=dict(l=50, r=100, t=60, b=40), title_x_position=0.5,
502
+ theme_mode=slide_styles.mode
503
+ )
504
+ slide_layout = GridLayout(
505
+ row_definitions=["auto", "auto", "auto", "auto"], col_definitions=["1fr"], gap=5,
506
+ cells=[
507
+ GridCell(row=1, col=1, element=TextElement(
508
+ text=slide_content_main_title, element_type="h4", font_weight=FontWeight.normal,
509
+ color=report_main_color, h_align=HorizontalAlign.left
510
+ ), padding="0 0 15px 0"),
511
+ GridCell(row=2, col=1, element=HtmlElement(html=monthly_chart_html), justify_self=HorizontalAlign.center, align_self=VerticalAlign.center),
512
+ GridCell(row=3, col=1, element=HtmlElement(html=annual_chart_html), justify_self=HorizontalAlign.center, align_self=VerticalAlign.center,
513
+ padding="15px 0 0 0")
514
+ ]
515
+ )
516
+ return Slide(
517
+ title="Portfolio Performance Summary", layout=slide_layout, footer_info=footer_text, style_theme=slide_styles
518
+ )
519
+
520
+
521
+ def data_table_summary_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
522
+ slide_content_title = "Transactions Summary"
523
+ table_headers = ["Date", "Deposits", "Withdrawals", "Net Amount"]
524
+ example_table_rows = [
525
+ ["05/01/2025", "", "1,200,000.50", "-1,200,000.50"], ["10/01/2025", "", "500,000.00", "-500,000.00"],
526
+ ["15/01/2025", "", "7,000,000.00", "-7,000,000.00"], ["16/01/2025", "6,500,000.00", "6,500,000.00", "0.00"],
527
+ ["02/02/2025", "10,000,000.00", "", "10,000,000.00"], ["08/02/2025", "", "10,000,000.00", "-10,000,000.00"],
528
+ ["12/02/2025", "", "100,000.75", "-100,000.75"], ["25/02/2025", "2,000,000.00", "3,500,000.00", "-1,500,000.00"],
529
+ ["10/03/2025", "", "250,000.00", "-250,000.00"], ["20/03/2025", "", "1,500,000.00", "-1,500,000.00"],
530
+ ["<b>Total</b>", "<b>18,500,000.00</b>", "<b>40,550,000.25</b>", "<b>-22,050,000.25</b>"]
531
+ ]
532
+ table_html = generic_plotly_table(
533
+ headers=table_headers, rows=example_table_rows, column_widths=[1, 1.5, 1.5, 1.5],
534
+ cell_align=['left', 'right', 'right', 'right'], header_align='center', table_height=400,
535
+ theme_mode=slide_styles.mode # Added theme_mode
536
+ )
537
+ slide_layout = GridLayout(
538
+ row_definitions=["auto", "1fr"], col_definitions=["1fr"], gap=10,
539
+ cells=[
540
+ GridCell(row=1, col=1, element=TextElement(
541
+ text=slide_content_title, element_type="h4", font_weight=FontWeight.normal,
542
+ color=report_main_color, h_align=HorizontalAlign.left
543
+ ), padding="0 0 15px 0"),
544
+ GridCell(row=2, col=1, element=HtmlElement(html=table_html), justify_self=HorizontalAlign.center, align_self=VerticalAlign.center,
545
+ padding="0 0 0 0")
546
+ ]
547
+ )
548
+ return Slide(
549
+ title="Data Table Summary", layout=slide_layout, footer_info=footer_text, style_theme=slide_styles
550
+ )
551
+
552
+
553
+ def contact_information_slide(footer_text: str, slide_styles: StyleSettings) -> Slide:
554
+ # For the specific #d6e2ff background:
555
+ contact_slide_specific_styles = copy.deepcopy(slide_styles)
556
+ contact_slide_specific_styles.background_color = "#d6e2ff"
557
+ # Adjust text colors if needed for contrast with the new background
558
+ contact_slide_specific_styles.heading_color = "#000000"
559
+ contact_slide_specific_styles.paragraph_color = "#000000"
560
+
561
+ el_main_sequence = TextElement(
562
+ text="Main Sequence", element_type="h1", font_weight=FontWeight.bold,
563
+ h_align=HorizontalAlign.left, color=contact_slide_specific_styles.heading_color
564
+ )
565
+ el_asset_management = TextElement(
566
+ text="Asset Management", element_type="h3", font_weight=FontWeight.normal,
567
+ h_align=HorizontalAlign.left, color=contact_slide_specific_styles.heading_color
568
+ )
569
+ el_address1 = TextElement(
570
+ text="Karlsplatz 3", element_type="h5", font_weight=FontWeight.normal,
571
+ h_align=HorizontalAlign.left, color=contact_slide_specific_styles.paragraph_color
572
+ )
573
+ el_address2 = TextElement(
574
+ text="1010 Vienna, Austria", element_type="h5", font_weight=FontWeight.normal,
575
+ h_align=HorizontalAlign.left, color=contact_slide_specific_styles.paragraph_color
576
+ )
577
+ slide_layout = GridLayout(
578
+ row_definitions=["18%", "auto", "auto", "auto", "auto", "1fr"],
579
+ col_definitions=["8%", "auto", "1fr"], gap=6,
580
+ cells=[
581
+ GridCell(row=2, col=2, element=el_main_sequence, justify_self=HorizontalAlign.left, align_self=VerticalAlign.bottom),
582
+ GridCell(row=3, col=2, element=el_asset_management, justify_self=HorizontalAlign.left, align_self=VerticalAlign.top),
583
+ GridCell(row=4, col=2, element=el_address1, justify_self=HorizontalAlign.left, align_self=VerticalAlign.bottom, padding="15px 0 0 0"),
584
+ GridCell(row=5, col=2, element=el_address2, justify_self=HorizontalAlign.left, align_self=VerticalAlign.top)
585
+ ]
586
+ )
587
+ return Slide(
588
+ title="Contact Information", layout=slide_layout, footer_info=footer_text, style_theme=contact_slide_specific_styles
589
+ )
590
+
591
+ def contact_information_slide() -> Slide:
592
+ slide_title = "Contact Details"
593
+ page_main_title_text = "Main Sequence | Asset Management"
594
+
595
+ contact_1_details = "<strong>CONTACT NAME 1</strong><br>contact1@example.com<br>Tel. (555) 100-1001"
596
+ contact_2_details = "<strong>CONTACT NAME 2</strong><br>contact2@example.com<br>Ext. 1002"
597
+ contact_3_details = "<strong>CONTACT NAME 3</strong><br>contact3@example.com<br>Ext. 1003"
598
+ contact_4_details = "<strong>CONTACT NAME 4</strong><br>contact4@example.com<br>Ext. 1004"
599
+ contact_5_details = "<strong>CONTACT NAME 5</strong><br>contact5@example.com<br>Ext. 1005"
600
+
601
+ address_details = "Placeholder Company Name<br>123 Anonymous Street, Placeholder City, ST 98765, Floor X."
602
+
603
+ contact_slide_cells = [
604
+ GridCell(
605
+ row=1, col=1, col_span=12,
606
+ element=TextH2(text=page_main_title_text, h_align=HorizontalAlign.center),
607
+ padding="5px 0 15px 0"
608
+ ),
609
+ GridCell(
610
+ row=2, col=4, col_span=3,
611
+ element=TextElement(text=contact_1_details, h_align=HorizontalAlign.center, v_align=VerticalAlign.top),
612
+ padding="10px"
613
+ ),
614
+ GridCell(
615
+ row=2, col=7, col_span=3,
616
+ element=TextElement(text=contact_2_details, h_align=HorizontalAlign.center, v_align=VerticalAlign.top),
617
+ padding="10px"
618
+ ),
619
+ GridCell(
620
+ row=3, col=3, col_span=2,
621
+ element=TextElement(text=contact_3_details, h_align=HorizontalAlign.center, v_align=VerticalAlign.top),
622
+ padding="10px"
623
+ ),
624
+ GridCell(
625
+ row=3, col=6, col_span=2,
626
+ element=TextElement(text=contact_4_details, h_align=HorizontalAlign.center, v_align=VerticalAlign.top),
627
+ padding="10px"
628
+ ),
629
+ GridCell(
630
+ row=3, col=9, col_span=2,
631
+ element=TextElement(text=contact_5_details, h_align=HorizontalAlign.center, v_align=VerticalAlign.top),
632
+ padding="10px"
633
+ ),
634
+ GridCell(
635
+ row=4, col=1, col_span=12,
636
+ element=TextElement(text=address_details, h_align=HorizontalAlign.center, element_type="p"),
637
+ padding="15px 0 5px 0"
638
+ )
639
+ ]
640
+
641
+ contacts_layout = GridLayout(
642
+ col_definitions=[
643
+ "1fr", "1fr", "1fr", "1fr", "1fr", "1fr",
644
+ "1fr", "1fr", "1fr", "1fr", "1fr", "1fr"
645
+ ],
646
+ row_definitions=["auto", "auto", "auto", "auto"],
647
+ cells=contact_slide_cells,
648
+ gap="5px",
649
+ width="100%",
650
+ height="auto"
651
+ )
652
+
653
+ contact_slide = Slide(
654
+ title=slide_title,
655
+ layout=contacts_layout,
656
+ footer_info="Confidential"
657
+ )
658
+ return contact_slide
659
+
660
+
661
+ def create_full_presentation() -> Presentation:
662
+ # Use the global `styles` object configured at the top for the presentation's base theme.
663
+ presentation_styles = styles
664
+
665
+ current_date_footer_text = "May 2025"
666
+
667
+ contact_slide_styles = copy.deepcopy(presentation_styles)
668
+ contact_slide_styles.background_color = "#d6e2ff"
669
+ contact_slide_styles.heading_color = "#000000" # Ensure text is readable on light blue
670
+ contact_slide_styles.paragraph_color = "#000000"
671
+ contact_slide_styles.light_paragraph_color = "#333333" # For footers etc. on this slide
672
+
673
+ presentation_slides = [
674
+ title_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
675
+ portfolio_detail_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
676
+ pie_chart_bars_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
677
+ generic_table_and_grouped_bar_chart_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
678
+ portfolio_performance_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
679
+ rate_sensitivity_analysis_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
680
+ issuer_performance_table_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
681
+ comparative_performance_charts_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
682
+ data_table_summary_slide(footer_text=current_date_footer_text, slide_styles=presentation_styles),
683
+ contact_information_slide(),
684
+ ]
685
+
686
+ return Presentation(
687
+ title="Main Sequence Monthly Report (Example)",
688
+ subtitle="May 2025",
689
+ slides=presentation_slides,
690
+ )
691
+
692
+
693
+ if __name__ == "__main__":
694
+ script_dir = Path(__file__).resolve().parent
695
+ output_html_path = script_dir / "ms_template_report.html" # Output to the same directory as the script
696
+ final_presentation = create_full_presentation()
697
+ try:
698
+ html_content = final_presentation.render()
699
+ with open(output_html_path, "w", encoding="utf-8") as f:
700
+ f.write(html_content)
701
+ print(f"Presentation rendered successfully to {output_html_path.resolve()}")
702
+ except Exception as e:
703
+ print(f"An error occurred during rendering: {e}")
704
+ import traceback
705
+
706
+ traceback.print_exc()