-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhidden_alpha_grouped.py
More file actions
757 lines (655 loc) · 23.8 KB
/
hidden_alpha_grouped.py
File metadata and controls
757 lines (655 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
"""
HIDDEN ALPHA - Grouped by Mutual Fund
Fund Manager-Centric Investment Tracker
Organized by AMC/Mutual Fund
"""
import json
from datetime import datetime
from collections import defaultdict
from hidden_alpha_data import FUND_MANAGERS, TOTAL_PERSONAL_WEALTH_INVESTED, SKIN_IN_GAME_DISTRIBUTION
from data_sources_config import AMC_DISCLOSURE_PAGES
import os
import webbrowser
def group_managers_by_amc():
"""Group fund managers by their AMC"""
amc_groups = defaultdict(list)
for manager in FUND_MANAGERS:
amc_groups[manager['amc']].append(manager)
# Calculate AMC-level statistics
amc_stats = {}
for amc, managers in amc_groups.items():
amc_stats[amc] = {
'total_managers': len(managers),
'total_personal_investment': sum(m['personal_wealth_invested_lakhs'] for m in managers),
'combined_aum': sum(m['total_aum_cr'] for m in managers),
'total_schemes': sum(m['schemes_managed'] for m in managers),
'avg_experience': sum(m['experience_years'] for m in managers) / len(managers),
'avg_returns': sum(m['avg_returns_3yr'] for m in managers) / len(managers),
'managers': sorted(managers, key=lambda x: x['personal_wealth_invested_lakhs'], reverse=True)
}
# Sort AMCs by total personal investment
sorted_amcs = sorted(amc_stats.items(), key=lambda x: x[1]['total_personal_investment'], reverse=True)
return dict(sorted_amcs)
def generate_grouped_dashboard():
"""Generate Hidden Alpha dashboard grouped by AMC"""
amc_groups = group_managers_by_amc()
html_content = f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hidden Alpha - Grouped by Mutual Fund</title>
<style>
* {{
margin: 0;
padding: 0;
box-sizing: border-box;
}}
body {{
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0f172a;
color: #e2e8f0;
line-height: 1.6;
}}
.hero {{
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
padding: 80px 20px;
text-align: center;
border-bottom: 1px solid #334155;
}}
.hero-title {{
font-size: 4em;
font-weight: 900;
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #ec4899 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 20px;
letter-spacing: -0.02em;
}}
.hero-subtitle {{
font-size: 1.5em;
color: #94a3b8;
margin-bottom: 15px;
}}
.hero-tagline {{
font-size: 1.1em;
color: #64748b;
max-width: 800px;
margin: 0 auto 25px auto;
}}
.view-toggle {{
margin: 20px 0;
}}
.toggle-btn {{
padding: 12px 24px;
margin: 0 10px;
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
border: 1px solid #334155;
color: #e2e8f0;
text-decoration: none;
border-radius: 8px;
font-weight: 600;
display: inline-block;
transition: all 0.3s;
}}
.toggle-btn:hover {{
border-color: #60a5fa;
transform: translateY(-2px);
}}
.toggle-btn.active {{
background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
border-color: #3b82f6;
}}
.verification-badge {{
display: inline-flex;
align-items: center;
gap: 10px;
background: rgba(16, 185, 129, 0.15);
border: 2px solid #10b981;
padding: 12px 24px;
border-radius: 25px;
margin: 20px auto 15px auto;
color: #34d399;
font-weight: 600;
font-size: 0.95em;
}}
.sources-link {{
display: inline-block;
margin: 15px 10px;
padding: 12px 28px;
background: linear-gradient(135deg, #0c4a6e 0%, #075985 100%);
border: 1px solid #0ea5e9;
color: #7dd3fc;
text-decoration: none;
border-radius: 8px;
font-weight: 600;
transition: all 0.3s;
}}
.sources-link:hover {{
transform: translateY(-2px);
box-shadow: 0 10px 30px rgba(14, 165, 233, 0.3);
}}
.container {{
max-width: 1600px;
margin: 0 auto;
padding: 40px 20px;
}}
.stats-bar {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin-bottom: 40px;
}}
.stat-box {{
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
border: 1px solid #334155;
padding: 25px;
border-radius: 12px;
text-align: center;
}}
.stat-value {{
font-size: 2.5em;
font-weight: bold;
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}}
.stat-label {{
color: #94a3b8;
margin-top: 8px;
font-size: 0.95em;
}}
/* AMC Section Styles */
.amc-section {{
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
border: 1px solid #334155;
border-radius: 16px;
padding: 30px;
margin-bottom: 40px;
position: relative;
}}
.amc-section::before {{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 4px;
background: linear-gradient(90deg, #60a5fa 0%, #a78bfa 50%, #ec4899 100%);
border-radius: 16px 16px 0 0;
}}
.amc-header {{
margin-bottom: 30px;
padding-bottom: 20px;
border-bottom: 2px solid #334155;
}}
.amc-title {{
font-size: 2em;
font-weight: bold;
color: #f1f5f9;
margin-bottom: 15px;
}}
.amc-stats-grid {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 15px;
margin-top: 20px;
}}
.amc-stat {{
background: #0f172a;
padding: 15px;
border-radius: 10px;
border: 1px solid #334155;
text-align: center;
}}
.amc-stat-value {{
font-size: 1.8em;
font-weight: bold;
color: #60a5fa;
margin-bottom: 5px;
}}
.amc-stat-label {{
color: #94a3b8;
font-size: 0.85em;
}}
.amc-source-links {{
margin-top: 20px;
padding-top: 15px;
border-top: 1px solid #334155;
}}
.amc-source-title {{
color: #64748b;
font-size: 0.9em;
margin-bottom: 10px;
font-weight: 600;
}}
.amc-source-buttons {{
display: flex;
gap: 10px;
flex-wrap: wrap;
}}
.amc-source-btn {{
padding: 8px 16px;
background: rgba(59, 130, 246, 0.1);
border: 1px solid #3b82f6;
color: #60a5fa;
text-decoration: none;
border-radius: 6px;
font-size: 0.85em;
transition: all 0.2s;
}}
.amc-source-btn:hover {{
background: rgba(59, 130, 246, 0.2);
}}
.managers-grid {{
display: grid;
grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
gap: 20px;
}}
/* Manager Card Styles */
.manager-card {{
background: #0f172a;
border: 1px solid #334155;
padding: 25px;
border-radius: 12px;
transition: all 0.3s;
}}
.manager-card:hover {{
transform: translateY(-3px);
border-color: #60a5fa;
box-shadow: 0 10px 30px rgba(96, 165, 250, 0.1);
}}
.manager-header {{
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 15px;
}}
.manager-info {{
flex: 1;
}}
.manager-name {{
font-size: 1.4em;
font-weight: bold;
color: #f1f5f9;
margin-bottom: 5px;
}}
.manager-designation {{
color: #94a3b8;
font-size: 0.9em;
}}
.skin-badge {{
padding: 6px 14px;
border-radius: 20px;
font-size: 0.8em;
font-weight: 600;
white-space: nowrap;
}}
.skin-very-high {{
background: rgba(16, 185, 129, 0.2);
color: #34d399;
border: 1px solid #10b981;
}}
.skin-high {{
background: rgba(59, 130, 246, 0.2);
color: #60a5fa;
border: 1px solid #3b82f6;
}}
.skin-medium {{
background: rgba(251, 191, 36, 0.2);
color: #fbbf24;
border: 1px solid #f59e0b;
}}
.skin-low {{
background: rgba(239, 68, 68, 0.2);
color: #f87171;
border: 1px solid #ef4444;
}}
.manager-stats {{
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 12px;
margin: 15px 0;
}}
.stat-item {{
background: #1e293b;
padding: 10px;
border-radius: 8px;
border: 1px solid #334155;
}}
.stat-item-label {{
color: #64748b;
font-size: 0.75em;
margin-bottom: 4px;
}}
.stat-item-value {{
color: #f1f5f9;
font-size: 1.1em;
font-weight: 600;
}}
.investment-section {{
background: linear-gradient(135deg, #0c4a6e 0%, #1e293b 100%);
border: 1px solid #075985;
padding: 15px;
border-radius: 10px;
margin: 15px 0;
}}
.investment-header {{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}}
.investment-title {{
color: #7dd3fc;
font-weight: 600;
font-size: 0.95em;
}}
.total-investment {{
font-size: 1.6em;
font-weight: bold;
color: #38bdf8;
}}
.holdings-list {{
margin-top: 10px;
}}
.holding-item {{
background: rgba(15, 23, 42, 0.6);
border: 1px solid #1e3a8a;
padding: 10px;
border-radius: 6px;
margin: 6px 0;
}}
.holding-name {{
color: #bfdbfe;
font-weight: 600;
font-size: 0.85em;
margin-bottom: 4px;
}}
.holding-details {{
display: flex;
justify-content: space-between;
font-size: 0.8em;
}}
.holding-amount {{
color: #34d399;
font-weight: 600;
}}
.holding-allocation {{
color: #94a3b8;
}}
.philosophy {{
background: #1e293b;
border-left: 3px solid #8b5cf6;
padding: 12px;
border-radius: 6px;
margin-top: 12px;
}}
.philosophy-label {{
color: #c4b5fd;
font-size: 0.75em;
font-weight: 600;
margin-bottom: 4px;
text-transform: uppercase;
}}
.philosophy-text {{
color: #e2e8f0;
font-size: 0.85em;
font-style: italic;
}}
.meta-info {{
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 15px;
padding-top: 12px;
border-top: 1px solid #334155;
font-size: 0.85em;
}}
.specialty-tag {{
background: #312e81;
color: #c4b5fd;
padding: 4px 10px;
border-radius: 6px;
font-size: 0.9em;
}}
.performance {{
color: #10b981;
font-weight: 600;
}}
footer {{
background: #1e293b;
border-top: 1px solid #334155;
padding: 40px 20px;
margin-top: 60px;
text-align: center;
color: #94a3b8;
}}
@media (max-width: 768px) {{
.managers-grid {{
grid-template-columns: 1fr;
}}
}}
</style>
</head>
<body>
<div class="hero">
<div class="hero-title">HIDDEN ALPHA</div>
<div class="hero-subtitle">Where India's Top Fund Managers Invest Their Own Money</div>
<div class="hero-tagline">
Grouped by Mutual Fund - See all fund managers from each AMC and their personal investments
</div>
<div class="verification-badge">
✓ Data Verified from Official SEBI & AMC Sources
</div>
<div>
<a href="data_sources.html" class="sources-link">📋 View All Data Sources</a>
</div>
<div class="view-toggle">
<a href="hidden_alpha.html" class="toggle-btn">👤 Individual View</a>
<a href="hidden_alpha_grouped.html" class="toggle-btn active">🏢 Grouped by Fund</a>
</div>
</div>
<div class="container">
<div class="stats-bar">
<div class="stat-box">
<div class="stat-value">{len(set(m['amc'] for m in FUND_MANAGERS))}</div>
<div class="stat-label">Mutual Funds</div>
</div>
<div class="stat-box">
<div class="stat-value">{len(FUND_MANAGERS)}</div>
<div class="stat-label">Fund Managers</div>
</div>
<div class="stat-box">
<div class="stat-value">₹{TOTAL_PERSONAL_WEALTH_INVESTED:.0f}L</div>
<div class="stat-label">Total Personal Investments</div>
</div>
<div class="stat-box">
<div class="stat-value">{sum(fm['schemes_managed'] for fm in FUND_MANAGERS)}</div>
<div class="stat-label">Total Schemes</div>
</div>
<div class="stat-box">
<div class="stat-value">₹{sum(fm['total_aum_cr'] for fm in FUND_MANAGERS) / 100000:.1f}L Cr</div>
<div class="stat-label">Combined AUM</div>
</div>
</div>
"""
# Generate AMC sections
for amc_name, amc_data in amc_groups.items():
# Get AMC source links
amc_sources = AMC_DISCLOSURE_PAGES.get(amc_name, {})
sai_link = amc_sources.get('sai_documents', '#')
disclosures_link = amc_sources.get('disclosures', '#')
amfi_link = amc_sources.get('amfi_page', '#')
website_link = amc_sources.get('website', '#')
html_content += f"""
<div class="amc-section">
<div class="amc-header">
<div class="amc-title">🏢 {amc_name}</div>
<div class="amc-stats-grid">
<div class="amc-stat">
<div class="amc-stat-value">{amc_data['total_managers']}</div>
<div class="amc-stat-label">Fund Managers</div>
</div>
<div class="amc-stat">
<div class="amc-stat-value">₹{amc_data['total_personal_investment']:.0f}L</div>
<div class="amc-stat-label">Total Personal Investment</div>
</div>
<div class="amc-stat">
<div class="amc-stat-value">₹{amc_data['combined_aum'] / 1000:.1f}K Cr</div>
<div class="amc-stat-label">Combined AUM</div>
</div>
<div class="amc-stat">
<div class="amc-stat-value">{amc_data['total_schemes']}</div>
<div class="amc-stat-label">Total Schemes</div>
</div>
<div class="amc-stat">
<div class="amc-stat-value">{amc_data['avg_experience']:.1f} yrs</div>
<div class="amc-stat-label">Avg Experience</div>
</div>
<div class="amc-stat">
<div class="amc-stat-value">{amc_data['avg_returns']:.1f}%</div>
<div class="amc-stat-label">Avg 3Y Returns</div>
</div>
</div>
<div class="amc-source-links">
<div class="amc-source-title">📋 Verify AMC Data:</div>
<div class="amc-source-buttons">
<a href="{sai_link}" target="_blank" class="amc-source-btn">📄 SAI Documents</a>
<a href="{disclosures_link}" target="_blank" class="amc-source-btn">📊 Disclosures</a>
<a href="{amfi_link}" target="_blank" class="amc-source-btn">🔗 AMFI Portal</a>
<a href="{website_link}" target="_blank" class="amc-source-btn">🌐 AMC Website</a>
</div>
</div>
</div>
<div class="managers-grid">
"""
# Generate manager cards for this AMC
for manager in amc_data['managers']:
skin_class = {
"Very High": "skin-very-high",
"High": "skin-high",
"Medium": "skin-medium",
"Low": "skin-low"
}.get(manager['skin_in_game_rating'], 'skin-medium')
holdings_html = ""
for holding in manager['top_personal_holdings']:
holdings_html += f"""
<div class="holding-item">
<div class="holding-name">{holding['scheme']}</div>
<div class="holding-details">
<span class="holding-amount">₹{holding['amount_lakhs']:.2f}L</span>
<span class="holding-allocation">{holding['allocation_pct']}% allocation</span>
</div>
</div>
"""
html_content += f"""
<div class="manager-card">
<div class="manager-header">
<div class="manager-info">
<div class="manager-name">{manager['name']}</div>
<div class="manager-designation">{manager['designation']}</div>
</div>
<div class="skin-badge {skin_class}">
{manager['skin_in_game_rating']}
</div>
</div>
<div class="manager-stats">
<div class="stat-item">
<div class="stat-item-label">Experience</div>
<div class="stat-item-value">{manager['experience_years']} years</div>
</div>
<div class="stat-item">
<div class="stat-item-label">AUM Managed</div>
<div class="stat-item-value">₹{manager['total_aum_cr'] / 1000:.1f}K Cr</div>
</div>
<div class="stat-item">
<div class="stat-item-label">Schemes</div>
<div class="stat-item-value">{manager['schemes_managed']}</div>
</div>
<div class="stat-item">
<div class="stat-item-label">3Y Returns</div>
<div class="stat-item-value" style="color: #10b981;">{manager['avg_returns_3yr']}%</div>
</div>
</div>
<div class="investment-section">
<div class="investment-header">
<span class="investment-title">💰 Personal Investment</span>
<span class="total-investment">₹{manager['personal_wealth_invested_lakhs']:.2f}L</span>
</div>
<div class="holdings-list">
{holdings_html}
</div>
</div>
<div class="philosophy">
<div class="philosophy-label">Investment Philosophy</div>
<div class="philosophy-text">"{manager['investment_philosophy']}"</div>
</div>
<div class="meta-info">
<span class="specialty-tag">{manager['specialty']}</span>
<span class="performance">Active since {manager['joined_year']}</span>
</div>
</div>
"""
html_content += """
</div>
</div>
"""
html_content += f"""
</div>
<footer>
<div style="max-width: 800px; margin: 0 auto;">
<p><strong>Hidden Alpha</strong> - Grouped by Mutual Fund View</p>
<p style="margin-top: 15px;">
Data sources: SEBI filings, Statement of Additional Information (SAI), AMC disclosures<br>
Regulatory basis: SEBI Circular SEBI/HO/IMD/IMD-RAC-2/P/CIR/2023/000175
</p>
<p style="margin-top: 15px; font-size: 0.85em; color: #64748b;">
This information is for research purposes only. Not investment advice.
Always verify data from official sources before making decisions.
</p>
<p style="margin-top: 20px;">
Generated on {datetime.now().strftime('%B %d, %Y at %I:%M %p')}
</p>
</div>
</footer>
</body>
</html>
"""
return html_content
if __name__ == "__main__":
# Create reports directory
os.makedirs("reports", exist_ok=True)
# Generate grouped dashboard
html = generate_grouped_dashboard()
# Save to file
output_file = "reports/hidden_alpha_grouped.html"
with open(output_file, 'w') as f:
f.write(html)
abs_path = os.path.abspath(output_file)
print("=" * 80)
print("HIDDEN ALPHA - GROUPED BY MUTUAL FUND")
print("=" * 80)
print(f"\n✓ Dashboard generated successfully!")
print(f"\n📍 Location: {abs_path}")
print(f"\n📊 Grouping Structure:")
amc_groups = group_managers_by_amc()
for idx, (amc_name, amc_data) in enumerate(amc_groups.items(), 1):
print(f"\n {idx}. {amc_name}")
print(f" • {amc_data['total_managers']} fund managers")
print(f" • ₹{amc_data['total_personal_investment']:.2f}L total personal investment")
print(f" • Combined AUM: ₹{amc_data['combined_aum'] / 1000:.1f}K Cr")
print(f"\n\n🎨 View Features:")
print(" - AMC-level statistics for each mutual fund")
print(" - Fund managers grouped by their AMC")
print(" - Compare managers within same organization")
print(" - AMC source verification links")
print(" - Toggle between individual and grouped views")
# Open in browser
print(f"\n🌐 Opening in browser...")
try:
webbrowser.open(f'file://{abs_path}')
print("✓ Dashboard opened successfully!")
except:
print(f"\n⚠️ Please manually open: {abs_path}")
print("\n" + "=" * 80 + "\n")