math-backend / static /index.html
engineportf's picture
Upload folder using huggingface_hub
b513eec verified
Raw
History Blame Contribute Delete
47.4 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wealth Engine | Institutional Quant Platform</title>
<link rel="stylesheet" href="/static/style.css?v=6">
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
<!-- Chart.js for Live Visuals -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
/* Fallback to prevent white screens on laptop WebGL/CSS failure */
body { background-color: #0f172a !important; color: #f8fafc; }
.glass-panel { transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.glass-panel:hover { transform: translateY(-5px) scale(1.02); }
</style>
</head>
<body class="theme-dark">
<!-- Vanta JS Fixed Background Container -->
<div id="vanta-bg" style="position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -2;"></div>
<!-- Cinematic Matrix Loading Overlay -->
<div id="matrix-loader" style="display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(5, 8, 20, 0.65); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 9999; flex-direction: column; justify-content: center; align-items: center; color: #3b82f6; font-family: monospace; overflow: hidden;">
<div class="noise-overlay" style="opacity: 0.05;"></div>
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; z-index: 2;">
<div style="font-size: 2rem; font-weight: bold; letter-spacing: 2px; margin-bottom: 2rem; text-shadow: 0 0 20px rgba(59,130,246,0.5);">ENGINE OPTIMIZING</div>
<div id="matrix-terminal" style="width: 600px; height: 300px; text-align: left; background: rgba(0,0,0,0.5); border: 1px solid rgba(59,130,246,0.3); padding: 1.5rem; border-radius: 8px; overflow: hidden; position: relative;">
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(rgba(59,130,246,0.1) 0%, transparent 10%, transparent 90%, rgba(59,130,246,0.1) 100%); pointer-events: none;"></div>
<div id="matrix-logs" style="display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.9rem; color: #818cf8; transform: translateY(0); transition: transform 0.1s linear;"></div>
</div>
<div style="margin-top: 2rem; width: 600px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden;">
<div id="matrix-progress" style="height: 100%; width: 0%; background: #3b82f6; box-shadow: 0 0 15px #3b82f6;"></div>
</div>
</div>
</div>
<!-- 1. Top Bar Ticker -->
<div class="market-ticker-bar">
<div class="ticker-content" id="liveTickerContent">
<span>Loading live market data...</span>
</div>
</div>
<!-- Ambient 3D Universe Background (Removed for Vanta.js) -->
<div class="noise-overlay"></div>
<!-- Navigation Bar -->
<nav>
<div class="nav-container">
<div class="nav-logo" onclick="switchView('hero')">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="url(#primary-gradient)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<defs>
<linearGradient id="primary-gradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#60a5fa" />
<stop offset="100%" stop-color="#818cf8" />
</linearGradient>
</defs>
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
</svg>
<span class="logo-text">WEALTH ENGINE</span>
</div>
<div class="nav-links">
<span class="nav-link active" data-target="hero" onclick="switchView('hero')">Home</span>
<span class="nav-link" data-target="sandbox" onclick="switchView('sandbox')">Sandbox</span>
<span class="nav-link" data-target="modelzoo" onclick="switchView('modelzoo')">Quantitative Alpha Models</span>
<span class="nav-link" data-target="docs" onclick="switchView('docs')">Engine Docs</span>
<span class="nav-link" data-target="howitworks" onclick="switchView('howitworks')">How It Works</span>
<span class="nav-link" data-target="terms" onclick="switchView('terms')">Terms of Use</span>
<span class="nav-link" onclick="logout()" style="color: #ef4444; display: flex; align-items: center; gap: 0.25rem;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path><polyline points="16 17 21 12 16 7"></polyline><line x1="21" y1="12" x2="9" y2="12"></line></svg>
Logout
</span>
</div>
</div>
</nav>
<!-- Main Content Container -->
<div class="main-content">
<!-- VIEW: HERO (The Hook) -->
<div id="view-hero" class="view-section active">
<div class="hero-layout">
<div class="hero-left">
<h1 class="hero-title">Institutional-grade optimization.<br>Scales to your understanding.</h1>
<p class="hero-subtitle">Construct resilient portfolios using deterministic mathematics, dynamic regime detection, and zero stochastic noise.</p>
<div class="hero-ctas">
<button class="btn-primary" onclick="switchView('sandbox')">
Enter Advanced Sandbox
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>
</button>
<button class="btn-secondary" onclick="document.getElementById('wizardOverlay').style.display='flex'">
Run Guided Wizard
</button>
</div>
</div>
<div class="hero-right">
<div class="glass-panel hook-panel" style="padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem;">
<h3 style="font-size: 1.2rem; display: flex; align-items: center; gap: 0.5rem;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#60a5fa" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>
Live Strategy Radar
</h3>
<p class="text-xs text-muted">Dynamically shifting factor exposures based on current market regime analysis.</p>
<div style="height: 250px; width: 100%; position: relative;">
<canvas id="heroRadarChart"></canvas>
</div>
</div>
</div>
</div>
</div>
<!-- VIEW: THE SANDBOX / ENGINE ROOM -->
<div id="view-sandbox" class="view-section">
<div class="page-header" style="text-align: center; margin-bottom: 2rem;">
<h1>The Engine Room</h1>
<p class="subtitle">Configure your matrix parameters and launch the optimization engine.</p>
</div>
<!-- Single Centered Form Layout -->
<div class="sandbox-container" style="max-width: 900px; margin: 0 auto;">
<div class="glass-panel">
<h3 class="panel-title" style="margin-bottom: 2rem;">Matrix Configuration</h3>
<form id="portfolioForm">
<div class="form-group">
<label for="tickers">Asset Universe (Tickers)</label>
<input type="text" id="tickers" placeholder="SPY, TLT, GLD, AAPL" value="SPY, TLT, GLD, AAPL, MSFT" required>
</div>
<div class="split-form-row">
<div class="form-group" style="margin-bottom: 0;">
<label for="capital">Capital Allocation</label>
<div class="input-wrapper prefix-wrapper">
<span class="prefix">$</span>
<input type="number" id="capital" value="100000" required>
</div>
</div>
<div class="form-group" style="margin-bottom: 0;">
<label for="risk">Risk Aversion (1 = Risk Lover, 10 = Risk Averse)</label>
<div class="range-container">
<input type="range" id="risk" min="1" max="10" value="5">
<div class="range-val" id="riskVal">5</div>
</div>
</div>
</div>
<div class="form-group">
<label for="model">Expected Return Vector (Alpha Engine)</label>
<select id="model">
<option value="1">CAPM (Capital Asset Pricing Model Prior)</option>
<option value="2">Black-Litterman (Market Equilibrium Prior)</option>
<option value="3">Bayesian Shrinkage (James-Stein Estimator)</option>
<option value="4">Multifactor Regression (Fama-French + Momentum)</option>
<option value="5" selected>Gradient Boosted Tree Ensemble (XGBoost & Lasso)</option>
<option value="6">End-to-End Differentiable Optimization (SPO+)</option>
<option value="7">Regime-Adaptive Hidden Markov Model (HMM)</option>
</select>
</div>
<div class="form-group">
<label for="allocation_engine">Constraint Matrix Layer</label>
<select id="allocation_engine">
<option value="1">Minimize Tail Risk (CVaR)</option>
<option value="2">Hierarchical Risk Parity (HRP)</option>
<option value="3">Exact True Risk Parity (ERC)</option>
</select>
</div>
<div class="toggles-container" style="margin-bottom: 2.5rem; justify-content: center; align-items: center;">
<label class="toggle-label"><input type="checkbox" id="allow_shorting" checked><span class="toggle-switch"></span>Allow Shorts</label>
<label class="toggle-label tooltip-anchor"><input type="checkbox" id="tax_enabled"><span class="toggle-switch"></span>Tax Optimized
<div class="tooltip-box">Injects an L1-Norm penalty vector scaling with asset turnover.</div>
</label>
<label class="toggle-label tooltip-anchor"><input type="checkbox" id="garch_enabled" checked><span class="toggle-switch"></span>GARCH Volatility
<div class="tooltip-box">Dynamically scales risk constraints using autoregressive volatility clustering.</div>
</label>
</div>
<div class="form-group" style="border-top: 1px solid rgba(255,255,255,0.1); padding-top: 1rem; margin-top: 1rem;">
<label style="cursor: pointer; display: flex; justify-content: space-between; align-items: center;" onclick="document.getElementById('advConstraints').style.display = document.getElementById('advConstraints').style.display === 'none' ? 'block' : 'none'">
<span>Advanced Constraints (Optional)</span>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>
</label>
<div id="advConstraints" style="display: none; margin-top: 1rem;">
<div class="form-group">
<label>Custom Limits (Format: Asset/Sector, Direction, Limit%)</label>
<p class="text-xs text-muted" style="margin-bottom: 0.5rem;">Examples: "AAPL, max, 5", "Sector:Tech, min, 10"</p>
<textarea id="custom_constraints_input" rows="3" placeholder="AAPL, max, 5&#10;Sector:Tech, min, 10" style="width: 100%; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.1); color: #fff; padding: 0.8rem; border-radius: 4px; font-family: monospace;"></textarea>
</div>
</div>
</div>
<button type="button" id="generateBtn" class="btn-primary" onclick="generateFullReport()" style="width: 100%; justify-content: center; padding: 1.2rem; font-size: 1.1rem; box-shadow: 0 4px 20px rgba(96, 165, 250, 0.3);">
<span>Execute Institutional Optimization</span>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"></polyline></svg>
</button>
</form>
</div>
</div>
<!-- THE ANALYTICS & STRESS-TESTING SUITE (Only shown after generation) -->
<div class="analytics-suite" id="analyticsSuite" style="display:none;">
<div class="suite-tabs">
<button class="suite-tab active" data-tab="backtest">Backtest Engine</button>
<button class="suite-tab" data-tab="stress">Macro Stress-Testing</button>
<button class="suite-tab" data-tab="risk">Structural Risk</button>
<button class="suite-tab" data-tab="code">Code & Math</button>
</div>
<div class="suite-content-container glass-panel">
<!-- The actual heavy report will load here via iframe, or we inject specific sections -->
<p class="text-center text-muted">Full optimization requires generating the deterministic report.</p>
<button class="btn-primary" style="margin: 2rem auto; display:block;" onclick="openReportFrame()">View Comprehensive Report</button>
</div>
</div>
</div>
<!-- VIEW: THE MODEL ZOO -->
<div id="view-modelzoo" class="view-section">
<div class="page-header" style="max-width: 800px; margin: 0 auto 3rem auto; text-align: center;">
<h1>Quantitative Alpha Models</h1>
<p class="subtitle" style="font-size: 1.1rem; line-height: 1.6;">Our predictive engines represent the bleeding edge of quantitative finance. We deploy both deterministic mathematical equilibrium models and robust machine learning ensembles to forecast expected returns. Below is the strict architectural breakdown of every engine available to you.</p>
</div>
<div class="cards-grid zoo-grid" style="grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));">
<div class="expandable-card">
<div class="card-header-flex">
<h3>1. CAPM (Capital Asset Pricing Model Prior)</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<div class="zoo-section">
<h4>The Core Mathematical Hypothesis</h4>
<p>Established by William Sharpe in 1964, CAPM posits that investors should only be compensated for "systematic risk"—risk that cannot be diversified away. Expected returns are purely a function of an asset's covariance with the broader market baseline (its Beta).</p>
<div class="math-box">E(R_i) = R_f + β_i(E(R_m) - R_f)</div>
</div>
<div class="zoo-section">
<h4>When It Shines vs. Fails</h4>
<p class="positive-text">✓ Exceptional in stable, highly correlated macro environments where Beta is a reliable, stationary predictor of upside.</p>
<p class="negative-text">✗ Breaks down structurally when idiosyncratic shocks occur (e.g. a specific sector collapsing while the index rallies) because it completely ignores individual asset momentum.</p>
</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>2. Gradient Boosted Tree Ensemble (XGBoost & Lasso)</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<div class="zoo-section">
<h4>The Core Mathematical Hypothesis</h4>
<p>Financial markets are deeply non-linear. This engine stacks gradient-boosted decision trees (XGBoost) to capture non-linear market regimes and anomalies, layered with a strictly penalized Lasso (L1 regularization) model to filter out extreme statistical noise. A Ridge Meta-Learner aggregates their predictions to ensure out-of-sample robustness.</p>
<div class="math-box">y_pred = α * XGB(x) + (1-α) * Lasso(x)<br>Loss = MSE + λ_1||w||_1</div>
</div>
<div class="zoo-section">
<h4>When It Shines vs. Fails</h4>
<p class="positive-text">✓ Dominates in highly complex, multi-factor datasets where linear assumptions (like CAPM) fail to capture hidden Alpha.</p>
<p class="negative-text">✗ Machine Learning inherently risks overfitting; it can misallocate capital if the market shifts into an unprecedented, structurally unobserved macroeconomic regime (e.g. Black Swan events).</p>
</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>3. Black-Litterman (Market Equilibrium Prior)</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<div class="zoo-section">
<h4>The Core Mathematical Hypothesis</h4>
<p>Pure historical optimization (Markowitz) leads to wildly concentrated portfolios that change radically day-to-day. Black-Litterman solves this using Bayesian shrinkage: it calculates the global market equilibrium (implied returns) as the mathematical "Prior", and updates it only if there is statistical evidence to deviate.</p>
<div class="math-box">E(R) = [(τΣ)^-1 + P^T Ω^-1 P]^-1 [(τΣ)^-1 Π + P^T Ω^-1 Q]</div>
</div>
<div class="zoo-section">
<h4>When It Shines vs. Fails</h4>
<p class="positive-text">✓ The undisputed gold standard for generating robust, highly diversified portfolios that do not whip-saw across rebalancing periods.</p>
<p class="negative-text">✗ Inherently conservative. By anchoring to the market equilibrium, it may under-allocate to early-stage, explosive breakout trends compared to a pure momentum model.</p>
</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>4. Multifactor Regression (Fama-French + Momentum)</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<div class="zoo-section">
<h4>The Core Mathematical Hypothesis</h4>
<p>An expansion of CAPM. Eugene Fama and Kenneth French proved that returns are not just driven by market Beta, but structurally driven by Small-Cap outperformance (SMB) and Value outperformance (HML). We append the Momentum factor (MOM) to ride prevailing trends.</p>
<div class="math-box">R_it - R_ft = α_i + β_1(R_mt - R_ft) + β_2 SMB_t + β_3 HML_t + β_4 MOM_t + ε_it</div>
</div>
<div class="zoo-section">
<h4>When It Shines vs. Fails</h4>
<p class="positive-text">✓ Extremely effective over long-term multi-year horizons, capitalizing on fundamental economic realities (value and size premiums).</p>
<p class="negative-text">✗ Vulnerable to "Factor Winter" where growth stocks dominate value for a decade (e.g. 2010-2020 Tech boom).</p>
</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>5. Bayesian Shrinkage (James-Stein Estimator)</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<div class="zoo-section">
<h4>The Core Mathematical Hypothesis</h4>
<p>Historically estimated returns are riddled with estimation error. James-Stein shrinkage mathematically "shrinks" extreme individual asset estimates toward the grand mean of the portfolio. This is a statistical guarantee against trusting outlier data.</p>
<div class="math-box">μ_JS = w * μ_i + (1 - w) * μ_global<br>where w is derived from variance of estimates.</div>
</div>
<div class="zoo-section">
<h4>When It Shines vs. Fails</h4>
<p class="positive-text">✓ Reduces the impact of "noise" in the data, preventing the optimizer from chasing an asset just because it had a lucky 30-day run.</p>
<p class="negative-text">✗ Can shrink truly exceptional, paradigm-shifting assets back down to the average, muting potential asymmetric upside.</p>
</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>6. End-to-End Differentiable Optimization (SPO+)</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<div class="zoo-section">
<h4>The Core Mathematical Hypothesis</h4>
<p>Traditional finance separates the prediction of returns from the optimization of weights. Predict-then-Optimize (SPO+) fuses them using a custom differentiable loss function. The machine learning model is trained to minimize the <em>regret of the portfolio's actual performance</em>, not just mean squared error of predictions.</p>
<div class="math-box">Loss_SPO+(f(x), c) = max_w { (2f(x) - c)^T w } - 2f(x)^T w*(c) + c^T w*(c)</div>
</div>
<div class="zoo-section">
<h4>When It Shines vs. Fails</h4>
<p class="positive-text">✓ Maximizes true financial utility by directly penalizing bad allocations rather than just inaccurate forecasts.</p>
<p class="negative-text">✗ Computationally expensive. Requires calculating optimization gradients through a convex solver at every training step.</p>
</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>7. Regime-Adaptive Hidden Markov Model (HMM)</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<div class="zoo-section">
<h4>The Core Mathematical Hypothesis</h4>
<p>Markets do not behave uniformly over time; they transition between hidden probabilistic states (Bull, Bear, Stagflation). The HMM assigns a probability that the market is in a specific latent state today, and dynamically adjusts the covariance and return expectations based strictly on the parameters of the detected regime.</p>
<div class="math-box">P(Z_t | X_{1:t}) ∝ P(X_t | Z_t) * Σ P(Z_t | Z_{t-1}) P(Z_{t-1} | X_{1:t-1})</div>
</div>
<div class="zoo-section">
<h4>When It Shines vs. Fails</h4>
<p class="positive-text">✓ Instantly reallocates defensive assets when shifting from a high-growth to a high-volatility regime.</p>
<p class="negative-text">✗ "Whip-saw" risk. If the market falsely signals a crash regime but instantly rebounds, the model may trap the portfolio in cash.</p>
</div>
</div>
</div>
</div>
</div>
<!-- VIEW: ENGINE DOCS -->
<div id="view-docs" class="view-section">
<div class="page-header" style="max-width: 800px; margin: 0 auto 3rem auto; text-align: center;">
<h1>Engine Documentation & Architecture</h1>
<p class="subtitle" style="font-size: 1.1rem; line-height: 1.6;">The underlying infrastructure of the platform is built on 100% deterministic convex optimization pipelines. Below is the strict mathematical specification of our constraint matrices and volatility overlays.</p>
</div>
<div class="cards-grid zoo-grid" style="grid-template-columns: 1fr; max-width: 900px; margin: 0 auto;">
<div class="expandable-card">
<div class="card-header-flex">
<h3>1. Dynamic GARCH(1,1) Volatility Modeling</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<p class="text-muted" style="font-size: 1.05rem; line-height: 1.7;">Standard historical volatility treats risk as a flat, static number. This is mathematically flawed. Financial markets exhibit "volatility clustering"—large changes are followed by large changes. Our GARCH (Generalized Autoregressive Conditional Heteroskedasticity) overlay dynamically detects expanding volatility regimes and proactively shrinks risk exposures <em>before</em> tail events crush the portfolio.</p>
<div class="math-box">σ²_t = ω + α * r²_{t-1} + β * σ²_{t-1}</div>
<p class="text-muted" style="margin-top: 1rem;">This equation updates today's volatility (σ²_t) using yesterday's shock (α * r²_{t-1}) and yesterday's variance (β * σ²_{t-1}), creating a memory effect that standard deviation lacks.</p>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>2. L1-Norm Tax Optimization Penalty</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<p class="text-muted" style="font-size: 1.05rem; line-height: 1.7;">High turnover strategies look great on paper but bleed capital to short-term capital gains taxes in the real world. When the Tax Optimization flag is toggled, we inject a strict L1-norm penalty vector directly into the convex solver. This forces the engine to mathematically weigh the theoretical alpha of a trade against the concrete tax drag of selling an existing position.</p>
<div class="math-box">Min: w^T Σ w + λ * || w - w_{prev} ||_1</div>
<p class="text-muted" style="margin-top: 1rem;">The absolute difference penalty (L1) forces the optimizer to prefer zero-turnover unless the marginal return strictly exceeds the tax boundary λ.</p>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>3. Allocation Engine: CVaR vs. Risk Parity</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<p class="text-muted" style="font-size: 1.05rem; line-height: 1.7;">
<strong>CVaR (Conditional Value at Risk):</strong> Unlike Variance (which penalizes upside growth), CVaR explicitly isolates and minimizes only the worst 5% of historical tail crashes.<br><br>
<strong>Hierarchical Risk Parity (HRP):</strong> Uses unsupervised machine learning (agglomerative clustering) to group correlated assets into sub-clusters, assigning capital purely based on risk distribution rather than unreliable return forecasts.<br><br>
<strong>Exact Risk Parity (ERC):</strong> A non-linear root-finding algorithm that guarantees every single asset contributes the exact same marginal risk to the total portfolio variance, ensuring true diversification.
</p>
<div class="math-box">Risk Contribution_i = w_i * (Σw)_i / (w^T Σ w) = 1/N</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>4. HMM Macro Regime Detection</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<p class="text-muted" style="font-size: 1.05rem; line-height: 1.7;">Financial markets operate in distinct probabilistic states (e.g., Bull, Bear, High-Inflation, Low-Growth). The engine uses a Hidden Markov Model (HMM) to classify the current state of the global economy in real-time. It then strictly filters historical covariances, ensuring the optimizer only trains on data from the <em>current</em> macro regime.</p>
<div class="math-box">Transition Matrix A_{ij} = P(Regime_{t}=j | Regime_{t-1}=i)</div>
</div>
</div>
</div>
</div>
<!-- VIEW: HOW IT WORKS -->
<div id="view-howitworks" class="view-section">
<div class="page-header" style="max-width: 800px; margin: 0 auto 3rem auto; text-align: center;">
<h1>How It Works: The Institutional Pipeline</h1>
<p class="subtitle" style="font-size: 1.1rem; line-height: 1.6;">Wealth Engine is not a simple calculator. It is a full-stack algorithmic trading pipeline. Below is the analytical breakdown of exactly how it transforms raw data into a strictly optimized portfolio.</p>
</div>
<div class="cards-grid zoo-grid" style="grid-template-columns: 1fr; max-width: 900px; margin: 0 auto;">
<div class="expandable-card">
<div class="card-header-flex">
<h3>Phase 1: Understanding the Current Economy</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<p class="text-muted" style="font-size: 1.05rem; line-height: 1.7;">The engine first connects to live market data to pull historical prices and interest rates. However, assuming the market behaves the same way all the time is dangerous. Our engine uses an algorithm to classify the current "Regime" of the global economy (e.g., Bull Market vs. High Volatility Selloff). By understanding the current environment, the engine only focuses on data that is relevant to today's reality, ignoring irrelevant past events.</p>
<div class="math-box">Regime = argmax_k P(Z_t = k | Market Data_{1:t})</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>Phase 2: Forecasting Future Returns</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<p class="text-muted" style="font-size: 1.05rem; line-height: 1.7;">Next, the engine needs to predict how much return each asset will generate. Instead of simple guessing, you choose a <strong>Quantitative Alpha Model</strong>. For example, if you choose our advanced ensemble, the engine calculates momentum, volatility, and market correlation for every asset. It then uses statistical learning to find patterns between these metrics and future returns, creating a precise mathematical forecast for your portfolio.</p>
<div class="math-box">E[R_{t+1}] = Model(Features_t, Parameters)</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>Phase 3: Risk Management & Allocation</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<p class="text-muted" style="font-size: 1.05rem; line-height: 1.7;">With the forecasts in hand, the engine enters the Convex Solver. This is where it calculates the exact percentage weighting of each asset to maximize your returns while capping your downside risk. It does this by measuring how assets move together (Covariance) and explicitly minimizing the damage of the worst 5% of historical market crashes. If you enable Tax Optimization, it will actively avoid proposing trades that trigger short-term capital gains taxes.</p>
<div class="math-box">w* = argmax (w^T E[R] - λ/2 w^T Σ w)</div>
</div>
</div>
<div class="expandable-card">
<div class="card-header-flex">
<h3>Phase 4: Stress Testing the Portfolio</h3>
<div class="card-expand-btn"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
<div class="card-body">
<p class="text-muted" style="font-size: 1.05rem; line-height: 1.7;">Before delivering the final allocation, the engine attempts to "break" the portfolio. It runs thousands of randomized future simulations (Monte Carlo) to see how the portfolio handles uncertainty. It also tests the portfolio against a simulated 2008 Financial Crisis and the 2020 COVID-19 shock. Only if the portfolio survives these rigorous thresholds does the engine finalize the output report.</p>
<div class="math-box">Path_{k, t+1} = Path_{k, t} * exp( (μ - σ²/2)dt + σ√dt Z )</div>
</div>
</div>
</div>
</div>
<!-- VIEW: TERMS OF USE -->
<div id="view-terms" class="view-section">
<div class="page-header" style="max-width: 800px; margin: 0 auto 3rem auto; text-align: center;">
<h1>Terms of Use</h1>
<p class="subtitle" style="font-size: 1.1rem; line-height: 1.6;">Please read these terms carefully before utilizing the Wealth Engine platform.</p>
</div>
<div class="glass-panel" style="max-width: 800px; margin: 0 auto; padding: 2.5rem; text-align: left; line-height: 1.8;">
<h3 style="margin-top: 0;">1. Not Financial Advice</h3>
<p class="text-muted">This platform is an experimental mathematical research tool, not a registered financial advisor. The outputs, forecasts, and allocations provided by the engine are for informational and research purposes only. They do not constitute financial, investment, legal, or tax advice.</p>
<h3>2. Historical Illusion</h3>
<p class="text-muted">All optimizations and predictive models rely heavily on historical data backtesting. Past performance is definitively not indicative of future results. Market dynamics can shift rapidly into unobserved regimes, rendering historical patterns obsolete.</p>
<h3>3. No Liability</h3>
<p class="text-muted">You are solely responsible for your own investment decisions. The creators, operators, and affiliates of Wealth Engine accept absolutely no liability for any financial losses, capital destruction, or damages resulting directly or indirectly from the use of this platform.</p>
<h3>4. Institutional Access Key</h3>
<p class="text-muted">Access to this platform is strictly limited to authorized users holding a valid institutional access key. You agree not to share, distribute, or otherwise compromise your access key. We reserve the right to revoke access at any time without notice.</p>
</div>
</div>
</div>
<!-- The Matrix Terminal Loading Overlay -->
<div class="loading-overlay" id="terminalOverlay" style="display: none;">
<div class="matrix-terminal">
<div class="terminal-header">
<span>Wealth Engine Compiler v4.2</span>
<span>STATUS: EXECUTING</span>
</div>
<div class="terminal-body" id="terminalBody">
<div class="loading-text">Initializing convex optimizer...</div>
</div>
</div>
</div>
<!-- Iframe to show the generated report -->
<div class="report-container" id="reportContainer">
<div class="report-header">
<button class="back-btn" onclick="closeReport()">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="19" y1="12" x2="5" y2="12"></line>
<polyline points="12 19 5 12 12 5"></polyline>
</svg>
Exit Report
</button>
</div>
<iframe id="report-view" src="about:blank"></iframe>
</div>
<!-- WIZARD MODAL -->
<div class="loading-overlay" id="wizardOverlay" style="display:none; z-index: 2000; align-items: center; justify-content: center; padding: 2rem;">
<div class="glass-panel" style="max-width: 500px; width: 100%; position: relative;">
<button onclick="document.getElementById('wizardOverlay').style.display='none'" style="position: absolute; right: 1rem; top: 1rem; background: none; border: none; color: #fff; cursor: pointer; font-size: 1.2rem;"></button>
<h2 style="color: #fff; margin-bottom: 0.5rem;">Advanced Wizard Builder</h2>
<p class="text-muted" style="margin-bottom: 2rem;">Let the engine auto-configure your portfolio parameters.</p>
<div id="wizardStep1" class="wizard-step active">
<div class="form-group">
<label>1. What is your primary macroeconomic view for the next 12 months?</label>
<select id="wizardMacro">
<option value="growth">Strong Economic Growth & Tech Dominance</option>
<option value="inflation">Sticky Inflation & High Rates</option>
<option value="recession">Impending Recession & Defensive Pivot</option>
<option value="uncertain">Highly Uncertain / Neutral</option>
</select>
</div>
<button class="btn-primary" style="width: 100%; justify-content: center; margin-top: 1rem;" onclick="nextWizardStep(2)">Next: Risk Tolerance</button>
</div>
<div id="wizardStep2" class="wizard-step" style="display: none;">
<div class="form-group">
<label>2. If the market drops 20%, what is your immediate reaction?</label>
<select id="wizardReaction">
<option value="buy">Buy more! (Risk Lover)</option>
<option value="hold">Hold steady. (Moderate)</option>
<option value="sell">Sell to avoid further losses. (Risk Averse)</option>
</select>
</div>
<div style="display: flex; gap: 1rem; margin-top: 1rem;">
<button class="btn-secondary" style="flex: 1;" onclick="nextWizardStep(1)">Back</button>
<button class="btn-primary" style="flex: 1; justify-content: center;" onclick="nextWizardStep(3)">Next: Final Setup</button>
</div>
</div>
<div id="wizardStep3" class="wizard-step" style="display: none;">
<div class="form-group">
<label>3. Select Investment Universe</label>
<select id="wizardBasket">
<option value="SPY, TLT, GLD, VNQ">All-Weather (Stocks, Bonds, Gold, Real Estate)</option>
<option value="QQQ, AAPL, MSFT, NVDA">Tech-Heavy Growth</option>
<option value="VYM, LQD, TLT, JNJ, PG">Safe Dividend Income</option>
<option value="SPY, QQQ, IWM, EFA, EEM">Global Equities Core</option>
</select>
</div>
<div style="display: flex; gap: 1rem; margin-top: 1rem;">
<button class="btn-secondary" style="flex: 1;" onclick="nextWizardStep(2)">Back</button>
<button class="btn-primary" style="flex: 1; justify-content: center;" onclick="runWizard()">Auto-Configure & Execute</button>
</div>
</div>
</div>
</div>
<script>
// Initialize Vanta 3D Background
if (window.VANTA) {
window.VANTA.NET({
el: "#vanta-bg",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x3b82f6,
backgroundColor: 0x0f172a,
points: 10.00,
maxDistance: 20.00,
spacing: 18.00,
showDots: true
});
}
</script>
<script src="/static/app.js?v=6"></script>
</body>
</html>