Grok 4.1 Fast· xai
Frontier Reasoning Traces
Build a CFO diversity in capital markets dashboard tracking issuer mix, investors, and…
- User
Build a CFO diversity in capital markets dashboard tracking issuer mix, investors, and outcomes.
- Assistant
Build a CFO diversity in capital markets dashboard tracking issuer mix, investors, and outcomes.
import dash
from dash import dcc, html, Input, Output, callback
import plotly.express as px
import plotly.graph_objects as go
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
# Sample data generation (in production, replace with real data from APIs like S&P, Bloomberg, or diversity databases)
np.random.seed(42)
n_issuers = 500
n_investors = 300
years = list(range(2020, 2024))
# Issuer data
issuer_data = []
for year in years:
for _ in range(n_issuers // len(years)):
diversity_score = np.random.choice(['Low', 'Medium', 'High'], p=[0.4, 0.4, 0.2])
gender = np.random.choice(['Male', 'Female', 'Non-binary'], p=[0.6, 0.35, 0.05])
ethnicity = np.random.choice(['White', 'Black', 'Hispanic', 'Asian', 'Other'], p=[0.65, 0.1, 0.1, 0.1, 0.05])
sector = np.random.choice(['Tech', 'Finance', 'Healthcare', 'Energy', 'Consumer'], p=[0.3, 0.25, 0.2, 0.15, 0.1])
issuance_size = np.random.lognormal(10, 2)
success_rate = 0.85 + 0.15 * (1 if diversity_score == 'High' else 0.5 if diversity_score == 'Medium' else 0)
issuer_data.append({
'Year': year,
'Issuer_ID': f'ISS_{len(issuer_data):04d}',
'Diversity_Score': diversity_score,
'CFO_Gender': gender,
'CFO_Ethnicity': ethnicity,
'Sector': sector,
'Issuance_Size_M': issuance_size,
'Success_Rate': success_rate,
'Avg_Return': np.random.normal(8 + 2 * (diversity_score == 'High'), 3)
})
issuers_df = pd.DataFrame(issuer_data)
# Investor data
investor_data = []
for year in years:
for _ in range(n_investors // len(years)):
diversity_score = np.random.choice(['Low', 'Medium', 'High'], p=[0.35, 0.45, 0.2])
gender = np.random.choice(['Male', 'Female', 'Non-binary'], p=[0.55, 0.4, 0.05])
ethnicity = np.random.choice(['White', 'Black', 'Hispanic', 'Asian', 'Other'], p=[0.6, 0.15, 0.1, 0.1, 0.05])
investor_type = np.random.choice(['VC', 'PE', 'Hedge Fund', 'Mutual Fund', 'Bank'])
aum = np.random.lognormal(12, 1.5)
performance = np.random.normal(10 + 1.5 * (diversity_score == 'High'), 4)
investor_data.append({
'Year': year,
'Investor_ID': f'INV_{len(investor_data):04d}',
'Diversity_Score': diversity_score,
'Lead_Gender': gender,
'Lead_Ethnicity': ethnicity,
'Type': investor_type,
'AUM_B': aum,
'Performance_%': performance
})
investors_df = pd.DataFrame(investor_data)
# Dashboard App
app = dash.Dash(__name__)
app.layout = html.Div([
html.H1("CFO Diversity in Capital Markets Dashboard",
style={'textAlign': 'center', 'color': '#2c3e50', 'marginBottom': 30}),
# KPIs Row
html.Div([
html.Div([
html.H3(id='total-issuers', className='kpi'),
html.P("Total Issuers Tracked")
], className='kpi-card'),
html.Div([
html.H3(id='diverse-cfo-pct', className='kpi'),
html.P("% Diverse CFOs (High/Med)")
], className='kpi-card'),
html.Div([
html.H3(id='total-investors', className='kpi'),
html.P("Total Investors Tracked")
], className='kpi-card'),
html.Div([
html.H3(id='avg-outcome', className='kpi'),
html.P("Avg Outcome (Returns/Perf %)")
], className='kpi-card'),
], className='kpi-row'),
# Filters
html.Div([
dcc.Dropdown(id='year-filter', options=[{'label': y, 'value': y} for y in years] + [{'label': 'All', 'value': 'All'}],
value='All', placeholder="Select Year", className='filter'),
dcc.Dropdown(id='sector-filter', options=[{'label': 'All', 'value': 'All'}] + [{'label': s, 'value': s} for s in issuers_df['Sector'].unique()],
value='All', placeholder="Filter by Sector", className='filter'),
], className='filter-row', style={'marginBottom': 30}),
# Charts Row 1: Issuer Mix
html.Div([
html.Div([
dcc.Graph(id='issuer-mix-pie')
], className='chart-card'),
html.Div([
dcc.Graph(id='issuer-gender-bar')
], className='chart-card'),
], className='chart-row'),
# Charts Row 2: Investors
html.Div([
html.Div([
dcc.Graph(id='investor-mix-pie')
], className='chart-card'),
html.Div([
dcc.Graph(id='investor-ethnicity-bar')
], className='chart-card'),
], className='chart-row'),
# Charts Row 3: Outcomes
html.Div([
html.Div([
dcc.Graph(id='outcomes-scatter')
], className='chart-card full-width'),
], className='chart-row'),
html.Div("Data: Simulated for demo. Integrate with real sources like S&P Capital IQ, Refinitiv, or DiversityInc APIs.",
style={'textAlign': 'center', 'color': '#7f8c8d', 'marginTop': 50})
], className='dashboard')
# Callbacks
@callback(
[Output('total-issuers', 'children'),
Output('diverse-cfo-pct', 'children'),
Output('total-investors', 'children'),
Output('avg-outcome', 'children')],
[Input('year-filter', 'value'),
Input('sector-filter', 'value')]
)
def update_kpis(year, sector):
df_iss = issuers_df if year == 'All' and sector == 'All' else issuers_df[(issuers_df['Year'] == year) & (issuers_df['Sector'] == sector)] if year != 'All' and sector != 'All' else issuers_df[issuers_df['Year'] == year] if year != 'All' else issuers_df[issuers_df['Sector'] == sector]
df_inv = investors_df if year == 'All' else investors_df[investors_df['Year'] == year]
total_iss = len(df_iss)
diverse_pct = (len(df_iss[df_iss['Diversity_Score'].isin(['Medium', 'High'])]) / total_iss * 100) if total_iss > 0 else 0
total_inv = len(df_inv)
avg_outcome = (df_iss['Avg_Return'].mean() + df_inv['Performance_%'].mean()) / 2 if len(df_iss) > 0 and len(df_inv) > 0 else 0
return f"{total_iss:,}", f"{diverse_pct:.1f}%", f"{total_inv:,}", f"{avg_outcome:.1f}%"
@callback(Output('issuer-mix-pie', 'figure'),
[Input('year-filter', 'value'), Input('sector-filter', 'value')])
def update_issuer_mix(year, sector):
df = issuers_df if year == 'All' and sector == 'All' else issuers_df[(issuers_df['Year'] == year) & (issuers_df['Sector'] == sector)] if year != 'All' and sector != 'All' else issuers_df[issuers_df['Year'] == year] if year != 'All' else issuers_df[issuers_df['Sector'] == sector]
fig = px.pie(df, names='Diversity_Score', title='Issuer CFO Diversity Mix')
return fig
@callback(Output('issuer-gender-bar', 'figure'),
[Input('year-filter', 'value'), Input('sector-filter', 'value')])
def update_issuer_gender(year, sector):
df = issuers_df if year == 'All' and sector == 'All' else issuers_df[(issuers_df['Year'] == year) & (issuers_df['Sector'] == sector)] if year != 'All' and sector != 'All' else issuers_df[issuers_df['Year'] == year] if year != 'All' else issuers_df[issuers_df['Sector'] == sector]
fig = px.bar(df, x='CFO_Gender', title='Issuer CFO Gender Breakdown', color='CFO_Gender')
return fig
@callback(Output('investor-mix-pie', 'figure'),
[Input('year-filter', 'value')])
def update_investor_mix(year):
df = investors_df if year == 'All' else investors_df[investors_df['Year'] == year]
fig = px.pie(df, names='Diversity_Score', title='Investor Diversity Mix')
return fig
@callback(Output('investor-ethnicity-bar', 'figure'),
[Input('year-filter', 'value')])
def update_investor_ethnicity(year):
df = investors_df if year == 'All' else investors_df[investors_df['Year'] == year]
fig = px.bar(df, x='Lead_Ethnicity', title='Investor Lead Ethnicity', color='Lead_Ethnicity')
return fig
@callback(Output('outcomes-scatter', 'figure'),
[Input('year-filter', 'value'), Input('sector-filter', 'value')])
def update_outcomes(year, sector):
df_iss_filt = issuers_df if year == 'All' and sector == 'All' else issuers_df[(issuers_df['Year'] == year) & (issuers_df['Sector'] == sector)] if year != 'All' and sector != 'All' else issuers_df[issuers_df['Year'] == year] if year != 'All' else issuers_df[issuers_df['Sector'] == sector]
df_inv_filt = investors_df if year == 'All' else investors_df[investors_df['Year'] == year]
# Combine for outcomes
df_iss_filt['Entity'] = 'Issuer'
df_iss_filt['Outcome'] = df_iss_filt['Avg_Return']
df_inv_filt['Entity'] = 'Investor'
df_inv_filt['Outcome'] = df_inv_filt['Performance_%']
df_combined = pd.concat([df_iss_filt[['Diversity_Score', 'Outcome', 'Entity']], df_inv_filt[['Diversity_Score', 'Outcome', 'Entity']]])
fig = px.scatter(df_combined, x='Diversity_Score', y='Outcome', color='Entity', title='Diversity Score vs. Outcomes (Returns/Performance %)',
trendline='ols', category_orders={'Diversity_Score': ['Low', 'Medium', 'High']})
return fig
# CSS for styling
app.index_string = '''
<!DOCTYPE html>
<html>
<head>
{%metas%}
<title>CFO Diversity Dashboard</title>
{%favicon%}
{%css%}
<style>
.dashboard { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 1400px; margin: 0 auto; padding: 20px; }
.kpi-row { display: flex; gap: 20px; margin-bottom: 30px; }
.kpi-card { flex: 1; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; border-radius: 10px; text-align: center; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.kpi { font-size: 2.5em; margin: 0; }
.filter-row { display: flex; gap: 20px; max-width: 600px; margin: 0 auto 30px; }
.filter { flex: 1; }
.chart-row { display: flex; gap: 20px; margin-bottom: 30px; }
.chart-card { flex: 1; background: white; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.full-width { flex: 2; }
@media (max-width: 768px) { .kpi-row, .chart-row, .filter-row { flex-direction: column; } }
</style>
</head>
<body>
{%app_entry%}
<footer>
{%config%}
{%scripts%}
{%renderer%}
</footer>
</body>
</html>
'''
if __name__ == '__main__':
print("🚀 Launching CFO Diversity Dashboard...")
print("📊 Copy-paste this code into a Python file (e.g., dashboard.py)")
print("📦 Install dependencies: pip install dash plotly pandas numpy")
print("⚙️ Run: python dashboard.py")
print("🌐 Open: http://127.0.0.1:8050/")
app.run_server(debug=True, port=8050)
pip install dash plotly pandas numpycfo_dashboard.py and run python cfo_dashboard.pyThis dashboard tracks issuer CFO mix (diversity pies/bars), investor mix (leadership diversity), and outcomes (correlated performance). Filters by year/sector. Fully interactive & responsive! 🔍✨