import React from 'react'; import { BookOpen, X, TrendingUp, BarChart2, ShieldAlert } from 'lucide-react'; import 'katex/dist/katex.min.css'; import { BlockMath, InlineMath } from 'react-katex'; interface SandboxMathModalProps { isOpen: boolean; onClose: () => void; } export default function SandboxMathModal({ isOpen, onClose }: SandboxMathModalProps) { React.useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') { onClose(); } }; if (isOpen) { window.addEventListener('keydown', handleKeyDown); } return () => { window.removeEventListener('keydown', handleKeyDown); }; }, [isOpen, onClose]); if (!isOpen) return null; return (
{/* Modal Header */}

Portfolio Sandbox - Math & Sizing Handbook

Institutional Portfolio Construction & Allocation Spec

{/* Modal Body */}
{/* Section A: Synthetic Portfolio Model & Asset Weightings */}

A. Synthetic Portfolio Model & Asset Weightings

The sandbox constructs a continuous synthetic asset representing your active weight allocations and its daily return track:

Active Percentage Weighting () Calculation:

Synthetic Portfolio Log Return ():

{/* Section B: Linear Mixed Effects Panel Regression (LMM) */}

B. Linear Mixed Effects Panel Regression (LMM)

Solves the system-wide macro response model across all historical event instances using a Swamy-Arora GLS estimator:

Panel Model Specification with VIX Controls:

where:
- is the relative day offset from event date .
- and are relative phase indicators.
- is the background market-wide volatility covariate.
- is the random group intercept (event instance shock).
- is the residual error.

{/* Section C: Kelly Criterion & Fractional Betting Sizing */}

C. Kelly Criterion & Fractional Betting Sizing

The Kelly Criterion optimizes allocation sizing to maximize the expected value of the logarithm of wealth, balancing capital preservation with growth:

Theoretical Kelly Fraction () Equation:

where:
- is the probability of a positive outcome (rebound or trade success).
- is the payout odds ratio (average win size divided by average loss size).

Fractional Kelly (Half-Kelly) Safety Buffer:

To mitigate estimation variance and protect against catastrophic drawdown due to model error or fat-tailed market returns, the cockpit clips the suggested sizing to a **Half-Kelly** multiplier ($0.5$).

); }