// frontend/src/components/InstitutionalPanel.tsx import React, { useState, useEffect } from 'react'; import { API_BASE } from '../config'; export const InstitutionalPanel: React.FC = () => { const [activeSubTab, setActiveSubTab] = useState<'alphaLab' | 'optimal' | 'statArb' | 'riskParity' | 'dsr' | 'lowLatency' | 'ofi' | 'multiAsset'>('alphaLab'); const [loading, setLoading] = useState(false); const [resultData, setResultData] = useState(null); const [alphaResearchData, setAlphaResearchData] = useState(null); const [error, setError] = useState(null); // Fetch precomputed Alpha Research Lab results on mount useEffect(() => { fetchLatestAlphaResearch(); }, []); const fetchLatestAlphaResearch = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/research/latest_results`); const data = await res.json(); if (data.success) { setAlphaResearchData(data); } else { setError(data.error || 'Failed to fetch research results'); } } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; const triggerRunAlphaExperiment = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/research/run`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ lookback_days: 20, holding_days: 5, cost_bps: 5.0, use_synthetic: true }) }); const data = await res.json(); if (data.success) { fetchLatestAlphaResearch(); } else { setError(data.error || 'Failed to trigger alpha experiment'); } } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; // OFI Trigger const runOFI = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/orderbook/ofi`, { method: 'POST' }); const data = await res.json(); if (data.success) setResultData(data.result); else setError(data.error || 'Failed to compute OFI'); } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; // Multi-Asset Backtest Trigger const runMultiAsset = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/portfolio/backtest-multi`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ tickers: ['AAPL', 'MSFT', 'TSLA', 'NVDA', 'AMZN', 'GOOGL', 'META'], period: '1y', top_n: 3 }) }); const data = await res.json(); if (data.success) setResultData(data.result); else setError(data.error || 'Failed to run multi-asset backtest'); } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; // 1. Almgren-Chriss Optimal Execution Demo Trigger const runOptimalExecution = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/optimal-execution/simulate`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ total_shares: 100000, num_intervals: 10, daily_volatility: 0.02, avg_daily_volume: 5000000.0, risk_aversion_lambda: 0.00001, current_price: 150.0 }) }); const data = await res.json(); if (data.success) setResultData(data); else setError(data.error || 'Failed to simulate optimal execution'); } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; // 2. StatArb Pairs Trading Trigger const runStatArb = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/stat-arb/run`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ticker_y: 'KO', ticker_x: 'PEP', period: '1y', z_entry: 2.0, z_exit: 0.5 }) }); const data = await res.json(); if (data.success) setResultData(data.result); else setError(data.error || 'Failed to run stat arb'); } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; // 3. Risk Parity Allocation Trigger const runRiskParity = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/portfolio/risk-parity`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ tickers: ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'TLT', 'GLD'], period: '1y' }) }); const data = await res.json(); if (data.success) setResultData(data.result); else setError(data.error || 'Failed to compute Risk Parity'); } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; // 4. Deflated Sharpe Ratio Trigger const runDSR = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/metrics/dsr`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ticker: 'TSLA', period: '1y', num_trials: 50 }) }); const data = await res.json(); if (data.success) setResultData(data.result); else setError(data.error || 'Failed to calculate DSR'); } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; // 5. Zero-Allocation Memory Profiling Trigger const runLowLatencyBench = async () => { setLoading(true); setError(null); try { const res = await fetch(`${API_BASE}/api/low-latency/benchmark`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ num_events: 500000 }) }); const data = await res.json(); if (data.success) setResultData(data.result); else setError(data.error || 'Failed to run low latency benchmark'); } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; return (

🏛️ Institutional Quantitative Architecture Terminal

专业量化研究与策略验证终端 (Institutional Quantitative Research Terminal)

PRO QUANT ENGINE ACTIVE
{/* Sub-tab Selectors */}
{error && (
⚠️ {error}
)} {/* SubTab Content */} {activeSubTab === 'alphaLab' && (

点位时间一致性与 Purged Walk-Forward Alpha 验证

Point-in-time universe across 38 liquid ETFs (94,040 rows OHLCV). Zero future leakage, 5d embargo, 5 bps friction.

{alphaResearchData && (
HISTORICAL SPAN {alphaResearchData.trading_dates} Trading Days
UNIVERSE SIZE {alphaResearchData.universe_size} Liquid ETFs
VALIDATION SCHEME Purged Walk-Forward (5d Embargo)
TRANSACTION FRICTION {alphaResearchData.cost_bps} bps
{/* Model Suite Comparison Table */}

Model Hierarchy Out-of-Sample Performance Table

{alphaResearchData.results.map((m: any, idx: number) => ( ))}
Model Name Rank IC Net Sharpe Max Drawdown Turnover Deflated Sharpe (DSR)
{m.model_name} {m.description} = 0 ? 'text-emerald-400' : 'text-rose-400'}`}> {m.rank_ic.toFixed(4)} = 0.5 ? 'text-emerald-400' : m.net_sharpe >= 0 ? 'text-amber-400' : 'text-rose-400'}`}> {m.net_sharpe.toFixed(2)} {(m.max_drawdown * 100).toFixed(1)}% {(m.turnover * 100).toFixed(1)}% {m.dsr.toFixed(2)}
{/* Feature Drift PSI Audit */}

Population Stability Index (PSI) Feature Drift Audit

{alphaResearchData.drift_audit.map((d: any, idx: number) => (
{d.feature} PSI: {d.psi.toFixed(4)}
{d.status}
))}
)}
)} {/* Subtab 1: Almgren-Chriss Execution */} {activeSubTab === 'optimal' && (

Almgren-Chriss Optimal Execution Simulator

Solves for the efficient execution frontier by balancing Permanent & Temporary Market Impact against Volatility Risk ($\lambda$).

{resultData && (
TOTAL SHARES {resultData.parameters?.total_shares?.toLocaleString()}
TOTAL EXPECTED COST ${resultData.total_expected_cost?.toFixed(2)}
RISK VARIANCE {resultData.total_variance?.toFixed(4)}
{resultData.trajectory?.map((row: any) => ( ))}
Interval Trade Shares Remaining Inventory Temp Impact ($)
T+{row.interval} {row.trade_shares?.toLocaleString()} {row.remaining_inventory?.toLocaleString()} ${row.temp_impact?.toFixed(4)}
)}
)} {/* Subtab 2: StatArb Pairs */} {activeSubTab === 'statArb' && (

Statistical Arbitrage & Cointegration Engine

Engle-Granger Cointegration Test + Ornstein-Uhlenbeck (OU) Mean Reversion Half-Life Estimation ($t_{1/2}$).

{resultData && (
HEDGE RATIO (BETA) {resultData.hedge_ratio?.toFixed(4)}
ADF P-VALUE {resultData.p_value?.toFixed(4)} {resultData.is_cointegrated ? '(COINTEGRATED)' : '(NOT COINT)'}
OU HALF-LIFE (DAYS) {resultData.half_life_days?.toFixed(2)} Days
TOTAL TRADES GENERATED {resultData.total_trades}
Current Spread Z-Score: {resultData.current_z_score?.toFixed(2)}
)}
)} {/* Subtab 3: Risk Parity */} {activeSubTab === 'riskParity' && (

Risk Parity & ERC Portfolio Optimization

Equal Risk Contribution (ERC) portfolio weights with Ledoit-Wolf Shrinkage Covariance estimation.

{resultData && (
PORTFOLIO ANN RETURN {(resultData.annualized_return * 100).toFixed(2)}%
PORTFOLIO ANN VOLATILITY {(resultData.annualized_volatility * 100).toFixed(2)}%
{Object.keys(resultData.weights || {}).map((ticker) => ( ))}
Asset Ticker ERC Weight (%) Risk Contribution (%)
{ticker} {(resultData.weights[ticker] * 100).toFixed(2)}% {(resultData.risk_contributions[ticker] * 100).toFixed(2)}%
)}
)} {/* Subtab 4: Deflated Sharpe Ratio */} {activeSubTab === 'dsr' && (

Deflated Sharpe Ratio (DSR) 夏普比率衰减与过拟合审计

Adjusts observed Sharpe Ratio for non-normal returns, skewness, kurtosis, and multiple testing trial count ($N$).

{resultData && (
OBSERVED SHARPE {resultData.observed_sharpe?.toFixed(2)}
MIN BENCHMARK SHARPE {resultData.benchmark_sharpe?.toFixed(2)}
DEFLATED SHARPE PROBABILITY = 0.95 ? 'text-emerald-400' : 'text-rose-400'}`}> {(resultData.dsr_probability * 100).toFixed(1)}%
OVERFITTING VERDICT {resultData.is_statistically_significant ? 'PASSED (GENUINE)' : 'FAILED (OVERFITTED)'}
)}
)} {/* Subtab 5: Low Latency Memory Profiler */} {activeSubTab === 'lowLatency' && (

Zero-Allocation Freelist Memory Profiler

Benchmarks custom C++/Python zero-allocation freelist memory pool against standard heap allocation across 500,000 order events.

{resultData && (
FREELIST EXEC TIME {resultData.freelist_execution_time_sec?.toFixed(4)}s
STANDARD HEAP TIME {resultData.standard_heap_execution_time_sec?.toFixed(4)}s
SPEEDUP FACTOR {resultData.speedup_factor?.toFixed(2)}x Faster
FREELIST ALLOCATIONS {resultData.freelist_allocations_count} (ZERO GC)
)}
)} {/* Subtab 6: OFI */} {activeSubTab === 'ofi' && (

Level-2 Order Flow Imbalance (OFI) & Micro-Price

Calculates Order Flow Imbalance (OFI) and Micro-Price (P_micro) for HFT lead-lag signals.

{resultData && (
{resultData.map((row: any, idx: number) => ( ))}
Bid Price Bid Vol Ask Price Ask Vol OFI Signal Micro-Price
${row.bid_price} {row.bid_vol} ${row.ask_price} {row.ask_vol} 0 ? 'text-emerald-400' : 'text-rose-400'}`}>{row.ofi} ${row.micro_price?.toFixed(2)}
)}
)} {/* Subtab 7: Multi-Asset */} {activeSubTab === 'multiAsset' && (

Multi-Asset Stock Pool Backtest Engine

Vectorized multi-asset stock pool simulator with daily alpha ranking, sector concentration caps & position limits.

{resultData && (
TOTAL RETURN {(resultData.total_return * 100).toFixed(2)}%
SHARPE RATIO {resultData.sharpe_ratio?.toFixed(2)}
MAX DRAWDOWN {(resultData.max_drawdown * 100).toFixed(2)}%
TOTAL REBALANCES {resultData.total_rebalance_count}
)}
)}
); };