Closes #016 - Deploy Native KaTeX Rig & Dual-Handbook System
This commit is contained in:
99
components/modules/macro/MacroBlueprintModal.tsx
Normal file
99
components/modules/macro/MacroBlueprintModal.tsx
Normal file
@@ -0,0 +1,99 @@
|
||||
import React from 'react';
|
||||
import { Settings, X } from 'lucide-react';
|
||||
|
||||
interface MacroBlueprintModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export default function MacroBlueprintModal({ isOpen, onClose }: MacroBlueprintModalProps) {
|
||||
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-350">
|
||||
|
||||
{/* 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-blue-400 to-indigo-400 bg-clip-text text-transparent flex items-center gap-2">
|
||||
<Settings className="w-5 h-5 text-blue-400" /> FRED Macro - 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">Macro Ingestion & Thresholds</h3>
|
||||
<p className="text-xs text-slate-400 mt-1">Operational details of Federal Reserve Economic Data (FRED) integration.</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-blue-400 uppercase tracking-wider font-mono">1. FRED Ingestion channels</h4>
|
||||
<p className="text-xs text-slate-400 leading-relaxed font-sans">
|
||||
Queries Federal Reserve API endpoints to ingest 21 distinct macro credit, inflation, labor, and housing vectors. Bypasses external calls in `DEV_MODE` to read from local cache backups.
|
||||
</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-blue-400 uppercase tracking-wider font-mono">2. Z-Score Normalization</h4>
|
||||
<p className="text-xs text-slate-400 leading-relaxed font-sans">
|
||||
Applies rolling historical mean and standard deviation scaling to convert raw indicators (e.g. housing starts, Delinquencies) into standardized Z-scores, indicating how far the current economy drifts from historical norms.
|
||||
</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-blue-400 uppercase tracking-wider font-mono">3. Cockpit Alerts System</h4>
|
||||
<p className="text-xs text-slate-400 leading-relaxed font-sans">
|
||||
Standardizes warnings into green (safe), amber (watch), and flashing red (recession risk) lights. Evaluates interest rate curves, inflation velocity, credit delinquencies, and housing contractions.
|
||||
</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">Cockpit Status Alert Rationale</h3>
|
||||
<div className="text-xs text-slate-400 space-y-3 leading-relaxed">
|
||||
<p>
|
||||
<strong className="text-blue-400 font-semibold">Inflation & Consumer Health Card:</strong> Sets off a `RED` trigger if CPI inflation YoY climbs above 3.0%, credit card delinquencies exceed 4.5%, or personal savings fall below 3.0%.
|
||||
</p>
|
||||
<p>
|
||||
<strong className="text-blue-400 font-semibold">Valuation & Liquidity Card:</strong> Sets off `RED` if S&P 500-to-GDP ratio (Buffett Indicator) rises past 150%, or the M2 money supply growth rate turns negative.
|
||||
</p>
|
||||
<p>
|
||||
<strong className="text-blue-400 font-semibold">Yield Curve & Credit Spread Card:</strong> Sets off `RED` if the 10Y-2Y yield curve spread inverts (spread < 0.0%) or high-yield credit spreads rise past 5.0%.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { LineChart, Line, ResponsiveContainer } from 'recharts';
|
||||
import 'katex/dist/katex.min.css';
|
||||
import MacroMathModal from './MacroMathModal';
|
||||
import MacroBlueprintModal from './MacroBlueprintModal';
|
||||
import {
|
||||
TrendingUp, Landmark, AlertCircle, BookOpen, Percent,
|
||||
ArrowDownRight, ArrowUpRight, Minus, Activity, ShieldAlert, Coins,
|
||||
@@ -37,6 +38,7 @@ export default function MacroIndicatorsDemo() {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [payload, setPayload] = useState<MacroDataPayload | null>(null);
|
||||
const [isMathModalOpen, setIsMathModalOpen] = useState(false);
|
||||
const [isBlueprintModalOpen, setIsBlueprintModalOpen] = useState(false);
|
||||
const [isAccordionOpen, setIsAccordionOpen] = useState(false); // Collapsible accordion closed by default
|
||||
|
||||
useEffect(() => {
|
||||
@@ -281,13 +283,21 @@ export default function MacroIndicatorsDemo() {
|
||||
<div className="flex items-center gap-3 w-full md:w-auto justify-end">
|
||||
<button
|
||||
onClick={() => setIsMathModalOpen(true)}
|
||||
className="flex items-center gap-1.5 px-4 py-2.5 rounded-xl bg-slate-955/80 hover:bg-slate-900 border border-slate-800 hover:border-slate-700 transition-all font-semibold text-xs tracking-wider text-indigo-400 w-full md:w-auto justify-center h-11 cursor-pointer"
|
||||
className="flex items-center gap-1.5 px-4 py-2.5 rounded-xl 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-indigo-400 w-full md:w-auto justify-center h-11 cursor-pointer"
|
||||
>
|
||||
<BookOpen className="w-4 h-4" />
|
||||
<span>📖 Quantitative Handbook</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setIsBlueprintModalOpen(true)}
|
||||
className="flex items-center gap-1.5 px-4 py-2.5 rounded-xl 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-indigo-400 w-full md:w-auto justify-center h-11 cursor-pointer animate-pulse-slow"
|
||||
>
|
||||
<Activity className="w-4 h-4" />
|
||||
<span>⚙️ Operational Blueprint</span>
|
||||
</button>
|
||||
|
||||
<div className="bg-slate-955/80 border border-slate-800 rounded-xl px-4 py-2 text-right shrink-0 h-11 flex flex-col justify-center">
|
||||
<div className="bg-slate-950/80 border border-slate-800 rounded-xl px-4 py-2 text-right shrink-0 h-11 flex flex-col justify-center">
|
||||
<div className="text-[9px] text-slate-555 uppercase font-mono">Last Update</div>
|
||||
<div className="font-mono text-xs text-slate-300">
|
||||
{new Date(payload.timestamp).toLocaleTimeString()}
|
||||
@@ -586,6 +596,7 @@ export default function MacroIndicatorsDemo() {
|
||||
</div>
|
||||
|
||||
<MacroMathModal isOpen={isMathModalOpen} onClose={() => setIsMathModalOpen(false)} />
|
||||
<MacroBlueprintModal isOpen={isBlueprintModalOpen} onClose={() => setIsBlueprintModalOpen(false)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export default function MacroMathModal({ isOpen, onClose }: MacroMathModalProps)
|
||||
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-5xl h-[85vh] flex flex-col overflow-hidden shadow-2xl relative text-slate-350">
|
||||
|
||||
{/* Modal Header */}
|
||||
@@ -70,13 +70,13 @@ export default function MacroMathModal({ isOpen, onClose }: MacroMathModalProps)
|
||||
<div className="bg-slate-950/40 p-5 rounded-2xl border border-slate-850 my-2 space-y-4">
|
||||
<div>
|
||||
<p className="text-xs text-slate-300 mb-2 font-semibold">Buffett Ratio Equation:</p>
|
||||
<BlockMath math="\\text{Buffett Ratio} = \\frac{\\text{Wilshire 5000 Total Market Index}}{\\text{Gross Domestic Product}} \\approx \\frac{\\text{S\\&P 500} \\times 1000}{\\text{Gross Domestic Product}}" />
|
||||
<BlockMath math="\text{Buffett Ratio} = \frac{\text{Wilshire 5000 Total Market Index}}{\text{Gross Domestic Product}} \approx \frac{\text{S\&P 500} \times 1000}{\text{Gross Domestic Product}}" />
|
||||
<p className="text-[10px] text-slate-500 mt-3 font-mono leading-relaxed">
|
||||
Where:
|
||||
<br />
|
||||
- <InlineMath math="\\text{Wilshire 5000 Total Market Index}" /> (originally FRED Series ID: 'WILL5000PR') represents the price performance of all active US equities. Due to the discontinuation of Wilshire series on FRED in June 2024, the S&P 500 index ('SP500') scaled by 1000 serves as the active proxy.
|
||||
- <InlineMath math="\text{Wilshire 5000 Total Market Index}" /> (originally FRED Series ID: 'WILL5000PR') represents the price performance of all active US equities. Due to the discontinuation of Wilshire series on FRED in June 2024, the S&P 500 index ('SP500') scaled by 1000 serves as the active proxy.
|
||||
<br />
|
||||
- <InlineMath math="\\text{Gross Domestic Product}" /> is nominal US GDP (FRED Series ID: 'GDPA').
|
||||
- <InlineMath math="\text{Gross Domestic Product}" /> is nominal US GDP (FRED Series ID: 'GDPA').
|
||||
</p>
|
||||
</div>
|
||||
<p className="text-xs leading-relaxed text-slate-400">
|
||||
@@ -96,20 +96,20 @@ export default function MacroMathModal({ isOpen, onClose }: MacroMathModalProps)
|
||||
<div className="bg-slate-950/40 p-5 rounded-2xl border border-slate-850 my-2 space-y-4">
|
||||
<div>
|
||||
<p className="text-xs text-slate-300 mb-2 font-semibold">Net Liquidity Equation:</p>
|
||||
<BlockMath math="\\text{Net Liquidity}_t = A_{\\text{Fed}, t} - \\text{TGA}_t - \\text{RRP}_t" />
|
||||
<BlockMath math="\text{Net Fed Liquidity}_t = A_{\text{Fed}, t} - \text{TGA}_t - \text{RRP}_t" />
|
||||
<p className="text-[10px] text-slate-500 mt-3 font-mono leading-relaxed">
|
||||
Where:
|
||||
<br />
|
||||
- <InlineMath math="A_{\\text{Fed}, t}" /> represents Total Federal Reserve Assets (the asset side of the Fed Balance Sheet).
|
||||
- <InlineMath math="A_{\text{Fed}, t}" /> represents Total Federal Reserve Assets (the asset side of the Fed Balance Sheet).
|
||||
<br />
|
||||
- <InlineMath math="\\text{TGA}_t" /> represents the Treasury General Account balance (the US Government's cash account held at the Federal Reserve).
|
||||
- <InlineMath math="\text{TGA}_t" /> represents the Treasury General Account balance (the US Government's cash account held at the Federal Reserve).
|
||||
<br />
|
||||
- <InlineMath math="\\text{RRP}_t" /> represents the Reverse Repurchase Agreement facility usage volume (liquidity parked overnight by money market funds at the Fed).
|
||||
- <InlineMath math="\text{RRP}_t" /> represents the Reverse Repurchase Agreement facility usage volume (liquidity parked overnight by money market funds at the Fed).
|
||||
</p>
|
||||
</div>
|
||||
<p className="text-xs leading-relaxed text-slate-400">
|
||||
<strong className="text-indigo-300">Liquidity Dynamics:</strong>
|
||||
An increase in <InlineMath math="A_{\\text{Fed}, t}" /> (Quantitative Easing) injects reserves into the banking system. Conversely, when the Treasury increases the <InlineMath math="\\text{TGA}" /> balance or when money market funds park cash in the <InlineMath math="\\text{RRP}" />, liquidity is drained from active circulation. A shrinking Net Liquidity Proxy acts as a powerful brake on risk assets (Equities & Cryptocurrencies), whereas expanding liquidity acts as a tailwind.
|
||||
An increase in <InlineMath math="A_{\text{Fed}, t}" /> (Quantitative Easing) injects reserves into the banking system. Conversely, when the Treasury increases the <InlineMath math="\text{TGA}" /> balance or when money market funds park cash in the <InlineMath math="\text{RRP}" />, liquidity is drained from active circulation. A shrinking Net Fed Liquidity Proxy acts as a powerful brake on risk assets (Equities & Cryptocurrencies), whereas expanding liquidity acts as a tailwind.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -125,7 +125,7 @@ export default function MacroMathModal({ isOpen, onClose }: MacroMathModalProps)
|
||||
<div className="bg-slate-950/40 p-5 rounded-2xl border border-slate-850 my-2 space-y-4">
|
||||
<div>
|
||||
<p className="text-xs text-slate-300 mb-2 font-semibold">2S10S Spread Equation:</p>
|
||||
<BlockMath math="\\text{Spread}_{2S10S} = Y_{10Y} - Y_{2Y}" />
|
||||
<BlockMath math="\text{Spread}_{2S10S} = Y_{10Y} - Y_{2Y}" />
|
||||
<p className="text-[10px] text-slate-500 mt-3 font-mono leading-relaxed">
|
||||
Where:
|
||||
<br />
|
||||
@@ -135,7 +135,7 @@ export default function MacroMathModal({ isOpen, onClose }: MacroMathModalProps)
|
||||
</p>
|
||||
</div>
|
||||
<p className="text-xs leading-relaxed text-slate-400">
|
||||
<strong className="text-indigo-300">Inversion & Un-Inversion:</strong> A negative spread (<InlineMath math="\\text{Spread}_{2S10S} < 0" />) represents an inverted yield curve, which has historically preceded US economic recessions. The "un-inversion" process, where the spread returns to positive territory, typically occurs during late-cycle phases or central bank pivot periods, signaling imminent macroeconomic contraction as short-term yields fall rapidly in anticipation of rate cuts.
|
||||
<strong className="text-indigo-300">Inversion & Un-Inversion:</strong> A negative spread (<InlineMath math="\text{Spread}_{2S10S} < 0" />) represents an inverted yield curve, which has historically preceded US economic recessions. The "un-inversion" process, where the spread returns to positive territory, typically occurs during late-cycle phases or central bank pivot periods, signaling imminent macroeconomic contraction as short-term yields fall rapidly in anticipation of rate cuts.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -151,13 +151,13 @@ export default function MacroMathModal({ isOpen, onClose }: MacroMathModalProps)
|
||||
<div className="bg-slate-950/40 p-5 rounded-2xl border border-slate-850 my-2 space-y-4">
|
||||
<div>
|
||||
<p className="text-xs text-slate-300 mb-2 font-semibold">Consumer Credit Distress Index (CDI):</p>
|
||||
<BlockMath math="\\text{CDI}_t = \\frac{\\text{Credit Card Delinquency Rate}_t}{\\text{Personal Savings Rate}_t}" />
|
||||
<BlockMath math="\text{CDI}_t = \frac{\text{Credit Card Delinquency Rate}_t}{\text{Personal Savings Rate}_t}" />
|
||||
<p className="text-[10px] text-slate-500 mt-3 font-mono leading-relaxed">
|
||||
Where:
|
||||
<br />
|
||||
- <InlineMath math="\\text{Credit Card Delinquency Rate}_t" /> measures the delinquency rate on credit card loans at top 100 commercial banks (FRED Series ID: 'DRCCLACBS').
|
||||
- <InlineMath math="\text{Credit Card Delinquency Rate}_t" /> measures the delinquency rate on credit card loans at top 100 commercial banks (FRED Series ID: 'DRCCLACBS').
|
||||
<br />
|
||||
- <InlineMath math="\\text{Personal Savings Rate}_t" /> represents personal savings as a percentage of disposable personal income (FRED Series ID: 'PSAVERT').
|
||||
- <InlineMath math="\text{Personal Savings Rate}_t" /> represents personal savings as a percentage of disposable personal income (FRED Series ID: 'PSAVERT').
|
||||
</p>
|
||||
</div>
|
||||
<p className="text-xs leading-relaxed text-slate-400">
|
||||
@@ -182,7 +182,7 @@ export default function MacroMathModal({ isOpen, onClose }: MacroMathModalProps)
|
||||
</div>
|
||||
<div>
|
||||
<strong className="text-indigo-300 block mb-1">II. Mortgage Applications Index Proxy [FRED: MORTGAGE30US]:</strong>
|
||||
Tracks the weekly demand for residential purchase mortgages. Because direct MBA applications index data is proprietary, the system computes a mortgage application index proxy derived from the 30-Year Fixed Rate Mortgage Average: <InlineMath math="\\text{Mortgage Index Proxy} = \\frac{1000}{\\text{30-Year Mortgage Rate}}" />.
|
||||
Tracks the weekly demand for residential purchase mortgages. Because direct MBA applications index data is proprietary, the system computes a mortgage application index proxy derived from the 30-Year Fixed Rate Mortgage Average: <InlineMath math="\text{Mortgage Index Proxy} = \frac{1000}{\text{30-Year Mortgage Rate}}" />.
|
||||
</div>
|
||||
<div>
|
||||
<strong className="text-indigo-300 block mb-1">III. Case-Shiller Home Price Index [FRED: CSUSHPISA]:</strong>
|
||||
|
||||
Reference in New Issue
Block a user