Closes #016 - Deploy Native KaTeX Rig & Dual-Handbook System
This commit is contained in:
99
components/modules/events/EconometricsBlueprintModal.tsx
Normal file
99
components/modules/events/EconometricsBlueprintModal.tsx
Normal file
@@ -0,0 +1,99 @@
|
||||
import React from 'react';
|
||||
import { Settings, X } from 'lucide-react';
|
||||
|
||||
interface EconometricsBlueprintModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export default function EconometricsBlueprintModal({ isOpen, onClose }: EconometricsBlueprintModalProps) {
|
||||
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 (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/85 backdrop-blur-md p-4 sm:p-6 md:p-8 animate-fade-in">
|
||||
<div className="bg-slate-900 border border-slate-800/80 rounded-3xl w-full max-w-4xl h-[80vh] flex flex-col overflow-hidden shadow-2xl relative text-slate-355">
|
||||
|
||||
{/* Modal Header */}
|
||||
<div className="flex justify-between items-center px-6 py-4 bg-slate-950/45 border-b border-slate-800/60">
|
||||
<div>
|
||||
<h2 className="text-base font-bold bg-gradient-to-r from-indigo-400 to-purple-400 bg-clip-text text-transparent flex items-center gap-2">
|
||||
<Settings className="w-5 h-5 text-indigo-400" /> Econometric Events - Operational Blueprint
|
||||
</h2>
|
||||
<p className="text-[10px] text-slate-500 font-mono">System User Manual & Interface Mechanics</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="text-slate-400 hover:text-slate-200 bg-slate-950/50 border border-slate-800 hover:border-slate-700 p-2 rounded-xl transition-all cursor-pointer flex items-center justify-center"
|
||||
aria-label="Close modal"
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Modal Body */}
|
||||
<div className="flex-1 overflow-y-auto p-6 sm:p-8 space-y-8 text-slate-355 scrollbar-thin">
|
||||
|
||||
<div className="border-b border-slate-800/80 pb-3">
|
||||
<h3 className="text-base font-bold text-slate-200">Event Studies & Models</h3>
|
||||
<p className="text-xs text-slate-400 mt-1">Operational details of the econometric event study solver.</p>
|
||||
</div>
|
||||
|
||||
{/* Core Mechanics */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div className="p-4 rounded-xl border border-slate-800/60 bg-slate-950/40 space-y-2">
|
||||
<h4 className="text-xs font-bold text-indigo-400 uppercase tracking-wider font-mono">1. Event Window Parameter Configuration</h4>
|
||||
<p className="text-xs text-slate-400 leading-relaxed font-sans">
|
||||
Allows defining the timeline partitions for analysis:
|
||||
* **Estimation Window**: Historical baseline period (e.g. 120 days) used to estimate the normal asset return relationships.
|
||||
* **Gap Window**: Separation buffer (e.g. 10 days) to prevent event-related leakages from skewing parameters.
|
||||
* **Event Window**: Analysis window surrounding the event day (e.g. [-5, +5]).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="p-4 rounded-xl border border-slate-800/60 bg-slate-950/40 space-y-2">
|
||||
<h4 className="text-xs font-bold text-indigo-400 uppercase tracking-wider font-mono">2. Abnormal Returns (AR)</h4>
|
||||
<p className="text-xs text-slate-400 leading-relaxed font-sans">
|
||||
Computes daily differences between the actual stock return and its expected "normal" return (using market-adjusted models or CAPM parameters derived during the estimation window).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="p-4 rounded-xl border border-slate-800/60 bg-slate-950/40 space-y-2">
|
||||
<h4 className="text-xs font-bold text-indigo-400 uppercase tracking-wider font-mono">3. Cumulative Abnormal Returns (CAR)</h4>
|
||||
<p className="text-xs text-slate-400 leading-relaxed font-sans">
|
||||
Integrates and sums the daily abnormal returns across the event window. Determines whether an event (e.g. earnings release, regulatory fine, supply-chain shock) created statistically significant excess wealth changes.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Interface Specifications */}
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-sm font-bold text-slate-200 border-b border-slate-800 pb-2">Interface Actions & Chart Displays</h3>
|
||||
<div className="text-xs text-slate-400 space-y-3 leading-relaxed">
|
||||
<p>
|
||||
<strong className="text-indigo-400 font-semibold">Event Parameters Input Mask:</strong> Edit estimation days, gap days, event horizons, and click **"Run Event Study Solver"**. Initiates server-side calculations.
|
||||
</p>
|
||||
<p>
|
||||
<strong className="text-indigo-400 font-semibold">CAR Event Charts:</strong> Renders a Recharts line chart illustrating the trajectory of Cumulative Abnormal Returns ($CAR$) across the event window. A significant deviation from zero indicates market inefficiency or corporate information shocks.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export default function EconometricsMathModal({ isOpen, onClose }: EconometricsM
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-slate-955/90 backdrop-blur-md p-4 sm:p-6 md:p-8">
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/90 backdrop-blur-md p-4 sm:p-6 md:p-8">
|
||||
<div className="bg-slate-900 border border-slate-800/80 rounded-3xl w-full max-w-4xl h-[80vh] flex flex-col overflow-hidden shadow-2xl relative text-slate-350">
|
||||
|
||||
{/* Modal Header */}
|
||||
@@ -61,7 +61,7 @@ export default function EconometricsMathModal({ isOpen, onClose }: EconometricsM
|
||||
If an active event's date is in the past:
|
||||
</p>
|
||||
<ul className="list-disc pl-5 text-xs text-slate-400 space-y-1">
|
||||
<li>FMP API fetches relative prices $P_t$ for $t \in [T-30, T+30]$ (60-day historical window).</li>
|
||||
<li>FMP API fetches relative prices <InlineMath math="P_t" /> for <InlineMath math="t \in [T-30, T+30]" /> (60-day historical window).</li>
|
||||
<li>Asset curves and the user's manual score are frozen under <code className="bg-slate-950 px-1 py-0.5 rounded text-[10px] text-slate-300">archivedEvents</code> in <code className="bg-slate-950 px-1 py-0.5 text-slate-300 rounded text-[10px]">econometrics_storage.json</code>.</li>
|
||||
<li>Future edits to the active matrix will <strong>never</strong> modify archived price vectors.</li>
|
||||
</ul>
|
||||
@@ -70,10 +70,10 @@ export default function EconometricsMathModal({ isOpen, onClose }: EconometricsM
|
||||
<div className="space-y-3">
|
||||
<h4 className="text-xs font-bold text-rose-400 uppercase tracking-wider font-mono">B. Endogenous Calibration</h4>
|
||||
<p className="text-xs leading-relaxed text-slate-400">
|
||||
Active future matrix cells pre-fill suggested scores by looking up the corresponding historical LMM coefficient <InlineMath math="\\beta_{\\text{asset}\\_\\text{event}\\_\\text{post}}" /> and scaling it to our native score scale:
|
||||
Active future matrix cells pre-fill suggested scores by looking up the corresponding historical LMM coefficient <InlineMath math="\beta_{\text{asset}\_\text{event}\_\text{post}}" /> and scaling it to our native score scale:
|
||||
</p>
|
||||
<div className="bg-slate-950/40 p-4 rounded-xl border border-slate-800/60 my-2">
|
||||
<BlockMath math="\\text{Score}_{\\text{suggested}} = \\max\\left(-3, \\min\\left(3, \\text{Round}(\\beta_{\\text{estimate}} \\times 100)\\right)\\right)" />
|
||||
<BlockMath math="\text{Score}_{\text{suggested}} = \max\left(-3, \min\left(3, \text{Round}(\beta_{\text{estimate}} \times 100)\right)\right)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -83,17 +83,17 @@ export default function EconometricsMathModal({ isOpen, onClose }: EconometricsM
|
||||
The engine estimates direct event drift and impact returns, isolating asset-level intercepts as random deviances and purging macro volatility using VIX indices:
|
||||
</p>
|
||||
<div className="bg-slate-950/40 p-4 rounded-xl border border-slate-800/60 my-2">
|
||||
<BlockMath math="Y_{it} = X_{it}\\beta + Z_{it}b_i + \\varepsilon_{it}" />
|
||||
<BlockMath math="Y_{it} = X_{it}\beta + Z_{it}b_i + \varepsilon_{it}" />
|
||||
<p className="text-[11px] text-slate-400 mt-2 font-mono leading-relaxed">
|
||||
{"Where:"}
|
||||
<br />
|
||||
{"- "}<InlineMath math="Y_{it}" />{" is the log-return "}<InlineMath math="\\ln(P_t/P_0)" />{" of asset "}<InlineMath math="i" />{" at relative index "}<InlineMath math="t \\in [-30, 30]" />{"."}
|
||||
{"- "}<InlineMath math="Y_{it}" />{" is the log-return "}<InlineMath math="\ln(P_t/P_0)" />{" of asset "}<InlineMath math="i" />{" at relative index "}<InlineMath math="t \in [-30, 30]" />{"."}
|
||||
<br />
|
||||
{"- "}<InlineMath math="X_{it}" />{" design matrix elements isolate Pre-Event Drift ("}<InlineMath math="t < 0" />{") and Post-Event Impact ("}<InlineMath math="t \\ge 0" />{") while controlling for systemic covariates (VIX)."}
|
||||
{"- "}<InlineMath math="X_{it}" />{" design matrix elements isolate Pre-Event Drift ("}<InlineMath math="t < 0" />{") and Post-Event Impact ("}<InlineMath math="t \ge 0" />{") while controlling for systemic covariates (VIX)."}
|
||||
<br />
|
||||
{"- "}<InlineMath math="b_i \\sim N(0, \\sigma_b^2)" />{" random intercept captures unique baseline asset variance."}
|
||||
{"- "}<InlineMath math="b_i \sim N(0, \sigma_b^2)" />{" random intercept captures unique baseline asset variance."}
|
||||
<br />
|
||||
{"- "}<InlineMath math="\\varepsilon_{it} \\sim N(0, \\sigma^2)" />{" residuals noise."}
|
||||
{"- "}<InlineMath math="\varepsilon_{it} \sim N(0, \sigma^2)" />{" residuals noise."}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -106,15 +106,15 @@ export default function EconometricsMathModal({ isOpen, onClose }: EconometricsM
|
||||
<div className="bg-slate-950/40 p-4 rounded-xl border border-slate-800/60 my-2 space-y-4">
|
||||
<div>
|
||||
<p className="text-xs text-slate-400 mb-1">Logistic Probability Projection:</p>
|
||||
<BlockMath math="P(\\text{Bullish}) = \\frac{1}{1 + e^{-\\text{Score}}}" />
|
||||
<BlockMath math="P(\text{Bullish}) = \frac{1}{1 + e^{-\text{Score}}}" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-slate-400 mb-1">Optimal Youden Index (J):</p>
|
||||
<BlockMath math="J = \\text{Sensitivity} + \\text{Specificity} - 1 = \\text{TPR} + (1 - \\text{FPR}) - 1" />
|
||||
<BlockMath math="J = \text{Sensitivity} + \text{Specificity} - 1 = \text{TPR} + (1 - \text{FPR}) - 1" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-slate-400 mb-1">{"Inverting probability optimal threshold "}<InlineMath math="P^*" />{" back to native score "}<InlineMath math="S^*" />{" via Logit:"}</p>
|
||||
<BlockMath math="S^* = \\ln\\left(\\frac{P^*}{1 - P^*}\\right)" />
|
||||
<BlockMath math="S^* = \ln\left(\frac{P^*}{1 - P^*}\right)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -126,7 +126,7 @@ export default function EconometricsMathModal({ isOpen, onClose }: EconometricsM
|
||||
</p>
|
||||
<div className="bg-slate-950/40 p-4 rounded-xl border border-slate-800/60 my-2 space-y-4">
|
||||
<div>
|
||||
<BlockMath math="\\hat{S}(t) = \\prod_{t_i \\le t} \\left(1 - \\frac{d_i}{n_i}\\right)" />
|
||||
<BlockMath math="\hat{S}(t) = \prod_{t_i \le t} \left(1 - \frac{d_i}{n_i}\right)" />
|
||||
<p className="text-[11px] text-slate-400 mt-2 font-mono leading-relaxed">
|
||||
{"Where:"}
|
||||
<br />
|
||||
@@ -137,7 +137,7 @@ export default function EconometricsMathModal({ isOpen, onClose }: EconometricsM
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-slate-400 mb-1">Reversal trigger with 1% Volatility Buffer:</p>
|
||||
<BlockMath math="\\text{Sign}(\\text{Score}) \\times \\text{Return} \\le -0.01" />
|
||||
<BlockMath math="\text{Sign}(\text{Score}) \times \text{Return} \le -0.01" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
import 'katex/dist/katex.min.css';
|
||||
import { BlockMath, InlineMath } from 'react-katex';
|
||||
import EconometricsMathModal from './EconometricsMathModal';
|
||||
import EconometricsBlueprintModal from './EconometricsBlueprintModal';
|
||||
import {
|
||||
Activity,
|
||||
BarChart4,
|
||||
@@ -247,6 +248,7 @@ export default function EventsDemo() {
|
||||
const [tauPre, setTauPre] = useState<number>(7);
|
||||
const [tauPost, setTauPost] = useState<number>(3);
|
||||
const [isMathModalOpen, setIsMathModalOpen] = useState<boolean>(false);
|
||||
const [isBlueprintModalOpen, setIsBlueprintModalOpen] = useState<boolean>(false);
|
||||
const [selectedSurvivalAsset, setSelectedSurvivalAsset] = useState<string>('Apple');
|
||||
const [showLmmDiagnostics, setShowLmmDiagnostics] = useState<boolean>(false);
|
||||
|
||||
@@ -604,11 +606,19 @@ export default function EventsDemo() {
|
||||
|
||||
<button
|
||||
onClick={() => setIsMathModalOpen(true)}
|
||||
className="flex items-center gap-1.5 px-3 py-2 rounded-lg bg-slate-950/80 hover:bg-slate-905 border border-slate-800 hover:border-slate-700 transition-all font-semibold text-xs tracking-wider text-rose-400"
|
||||
className="flex items-center gap-1.5 px-3 py-2 rounded-lg bg-slate-950/80 hover:bg-slate-900 border border-slate-800 hover:border-slate-700 transition-all font-semibold text-xs tracking-wider text-rose-400"
|
||||
>
|
||||
<BookOpen className="w-3.5 h-3.5" />
|
||||
<span>📖 Quantitative Handbook</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setIsBlueprintModalOpen(true)}
|
||||
className="flex items-center gap-1.5 px-3 py-2 rounded-lg bg-slate-950/80 hover:bg-slate-900 border border-slate-800 hover:border-slate-700 transition-all font-semibold text-xs tracking-wider text-rose-400 animate-pulse-slow"
|
||||
>
|
||||
<Compass className="w-3.5 h-3.5" />
|
||||
<span>⚙️ Operational Blueprint</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1326,6 +1336,7 @@ export default function EventsDemo() {
|
||||
</div>
|
||||
|
||||
<EconometricsMathModal isOpen={isMathModalOpen} onClose={() => setIsMathModalOpen(false)} />
|
||||
<EconometricsBlueprintModal isOpen={isBlueprintModalOpen} onClose={() => setIsBlueprintModalOpen(false)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user