From 2f0599a3cda206ca9de4f8610f8c7b81642424f0 Mon Sep 17 00:00:00 2001 From: Antigravity Agent Date: Sun, 14 Jun 2026 12:41:18 +0200 Subject: [PATCH] Closes #017 - Fix KaTeX rendering corruption and inject detailed blueprint contents --- DEV_LOG.md | 20 +++++++ QUANT_ROADMAP.md | 3 + components/modules/crypto/CryptoMathModal.tsx | 44 +++++++------- .../events/EconometricsBlueprintModal.tsx | 57 ++++++++++++------- .../modules/scanner/ScannerBlueprintModal.tsx | 52 ++++++++++++----- .../modules/tech/TechBlueprintModal.tsx | 50 +++++++++++----- 6 files changed, 154 insertions(+), 72 deletions(-) diff --git a/DEV_LOG.md b/DEV_LOG.md index 95ff58a..3365f27 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -182,3 +182,23 @@ This document tracks all modifications, npm packages, active compilation states, ### Active Bugs / Compile Status * **Active Bugs**: None. * **Type Checker Status**: Verified 100% clean compilation (`npx tsc --noEmit` returns exit code 0). + +--- + +## [2026-06-14] - Master-Pattern KaTeX Fix & Deep Blueprint Injection (#ISSUE-017) + +### Added +* **Detailed Mathematics in Operational Blueprints**: Expanded and injected formal quantitative formulas, parameter definitions, and estimation window thresholds inside: + * `components/modules/scanner/ScannerBlueprintModal.tsx` (Welles Wilder RSI-14 EMA smoothing, 52-Week Drop thresholds, and FMP Valuation Overlay to Forward P/E transitions). + * `components/modules/events/EconometricsBlueprintModal.tsx` (Event Studies layout, 120-day Estimation Window, 10-day Gap Isolation Shield, and Cumulative Abnormal Returns CAR aggregation formulas). + * `components/modules/tech/TechBlueprintModal.tsx` (AI CapEx cycle parameters, SEC 10-Q filing parsers, Monetization Gap, and Supply-Chain Velocity Index formulas). + +### Modified +* **KaTeX "Kaputt-repariert" Mitigation**: Audited and rewritten `components/modules/crypto/CryptoMathModal.tsx` to completely resolve formatting corruption by establishing the golden master single-backslash pattern and converting all double backslashes (`\\`) in math strings to single backslashes (`\`), with correct matrix formatting. +* **System-Wide Variable Unification**: Unified and wrapped all mathematical variables (such as `S_1`, `S_2`, `S_3`, `S_i`, `S_j`, `w`, `k` in Crypto, and other parameters across Scanner, Macro, and Econometrics modals) inside native `` components. +* **`QUANT_ROADMAP.md`**: Updated Section 1 and registered Phase 5.5. + +### Active Bugs / Compile Status +* **Active Bugs**: None. +* **Type Checker Status**: Verified 100% clean type verification (`npx tsc --noEmit` returns exit code 0). + diff --git a/QUANT_ROADMAP.md b/QUANT_ROADMAP.md index 046755f..c3ce4f0 100644 --- a/QUANT_ROADMAP.md +++ b/QUANT_ROADMAP.md @@ -26,6 +26,9 @@ This document serves as the permanent, centralized system architecture design an * **Phase 5.0: Native KaTeX Rig & Dual-Handbook System** * *Features*: Refactored all 8 sandbox modules to feature a unified twin-modal header layout (`📖 Quantitative Handbook` and `⚙️ Operational Blueprint`). Replaced all inline string-escaped LaTeX with native React `react-katex` calls to completely eliminate escaping anomalies. Authored 8 new functional operational blueprints explaining scanner, whale, and math mechanics. * *Status*: **Fully Operational (Production Lock)**. +* **Phase 5.5: Master-Pattern KaTeX Fix & Operational Blueprint Injection** + * *Features*: Completely repaired remaining KaTeX rendering corruption in `CryptoMathModal.tsx` by converting it to the golden master single-backslash pattern. Unified math variables wrapping in text blocks across all math modals. Injected ultra-detailed operational specification matrices (Welles Wilder EMAs, Event Study isolation shields, abnormal returns, CAR, Monetization Gap, and Supply-Chain Velocity Index) directly into the operational blueprint modals for the Scanner, Econometrics, and Tech Silo modules. + * *Status*: **Fully Operational (Production Lock)**. --- diff --git a/components/modules/crypto/CryptoMathModal.tsx b/components/modules/crypto/CryptoMathModal.tsx index 995440d..93cda45 100644 --- a/components/modules/crypto/CryptoMathModal.tsx +++ b/components/modules/crypto/CryptoMathModal.tsx @@ -62,15 +62,15 @@ export default function CryptoMathModal({ isOpen, onClose }: CryptoMathModalProp

- State 1 (S1) + State 1 () Bearish Squeeze / Crackdown
- State 2 (S2) + State 2 () Consolidation / Mean Reversion
- State 3 (S3) + State 3 () Parabolic Bull Run
@@ -83,9 +83,9 @@ export default function CryptoMathModal({ isOpen, onClose }: CryptoMathModalProp Calculates transition probabilities over rolling 90-day return vectors:

- +

- {"where "}{" represents the frequency probability of moving from State i to State j."} + where represents the frequency probability of moving from State to State .

@@ -97,13 +97,13 @@ export default function CryptoMathModal({ isOpen, onClose }: CryptoMathModalProp When external alpha inputs (e.g. Funding Rate anomalies, Whale inflows) occur, state probabilities are updated using Bayes' theorem:

- +

- {"Where:"} + Where:
- {"- "}{" is the prior state probability from the Markov transition matrix."} + - is the prior state probability from the Markov transition matrix.
- {"- "}{" is the conditional likelihood of observing this whale spike / funding squeeze in State i."} + - is the conditional likelihood of observing this whale spike / funding squeeze in State .

@@ -125,7 +125,7 @@ export default function CryptoMathModal({ isOpen, onClose }: CryptoMathModalProp

The Random Forest ensemble evaluates 10 non-linear decision trees to output the short-term and medium-term trend probabilities:

- + @@ -138,23 +138,23 @@ export default function CryptoMathModal({ isOpen, onClose }: CryptoMathModalProp

1. Prior Distribution (Accuracy History):

- +

- where represents historical prediction successes and represents false alarms. + where represents historical prediction successes and represents false alarms.

2. Likelihood Formulation (Binomial pseudo-observations):

- +

- where is the number of simulated successes and is the number of simulated failures. + where is the number of simulated successes and is the number of simulated failures.

3. Conjugate Posterior Update:

- +
@@ -163,20 +163,20 @@ export default function CryptoMathModal({ isOpen, onClose }: CryptoMathModalProp

F. Mathematical Proof of Posterior Mean Integration

- To resolve a single operational point-estimate from our posterior distribution, we integrate out the continuous parameter to calculate the mathematical expectation of the posterior distribution: + To resolve a single operational point-estimate from our posterior distribution, we integrate out the continuous parameter to calculate the mathematical expectation of the posterior distribution:

Posterior Expectation Integral Proof:

- +

- Using the definition of the Beta function and the recurrence relation : + Using the definition of the Beta function and the recurrence relation :

- - + +

Expanded Workstation Implementation Formula:

- +

- This formulation ensures that if the prior model is highly accurate (large ), the raw ML signal is smoothed towards historical baseline expectations. If historical errors are high, the prior variance restricts overreaction to noisy signals. + This formulation ensures that if the prior model is highly accurate (large ), the raw ML signal is smoothed towards historical baseline expectations. If historical errors are high, the prior variance restricts overreaction to noisy signals.

diff --git a/components/modules/events/EconometricsBlueprintModal.tsx b/components/modules/events/EconometricsBlueprintModal.tsx index 6aa4c95..2c352b9 100644 --- a/components/modules/events/EconometricsBlueprintModal.tsx +++ b/components/modules/events/EconometricsBlueprintModal.tsx @@ -1,5 +1,7 @@ import React from 'react'; import { Settings, X } from 'lucide-react'; +import 'katex/dist/katex.min.css'; +import { BlockMath, InlineMath } from 'react-katex'; interface EconometricsBlueprintModalProps { isOpen: boolean; @@ -25,7 +27,7 @@ export default function EconometricsBlueprintModal({ isOpen, onClose }: Economet return (
-
+
{/* Modal Header */}
@@ -49,33 +51,48 @@ export default function EconometricsBlueprintModal({ isOpen, onClose }: Economet

Event Studies & Models

-

Operational details of the econometric event study solver.

+

Operational details of the econometric event study solver, timeline configuration, and abnormal returns calculations.

{/* Core Mechanics */} -
-
-

1. Event Window Parameter Configuration

-

- 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]). -

+
+
+

1. Event Window Configuration

+
+

+ Allows defining the timeline partitions for analysis. The **120-day Estimation Window** serves to isolate market beta () and baseline alpha () from standard market returns using OLS estimation: +

+ +

+ The **10-day Gap Window** acts as a strict mathematical **Isolation Shield** to prevent information leakage, pre-event front-running, or insider-related abnormal volatility from contaminating the baseline parameters. +

+
-
+

2. Abnormal Returns (AR)

-

- 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). -

+
+

+ Computes daily differences between the actual stock return () and its expected normal return: +

+ +

+ where and are the OLS parameters estimated over the estimation window, and represents the actual market benchmark index return on day . This isolates the asset's idiosyncratic reaction to event-specific shocks. +

+
-
+

3. Cumulative Abnormal Returns (CAR)

-

- 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. -

+
+

+ Integrates and sums the daily abnormal returns across the specified event window to track the cumulative market shocks: +

+ +

+ where and define the bounds of the event window. This determines whether an event (e.g. earnings release, regulatory fine, supply-chain shock) created statistically significant excess wealth changes. +

+
@@ -87,7 +104,7 @@ export default function EconometricsBlueprintModal({ isOpen, onClose }: Economet Event Parameters Input Mask: Edit estimation days, gap days, event horizons, and click **"Run Event Study Solver"**. Initiates server-side calculations.

- CAR Event Charts: 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. + CAR Event Charts: Renders a Recharts line chart illustrating the trajectory of Cumulative Abnormal Returns () across the event window. A significant deviation from zero indicates market inefficiency or corporate information shocks.

diff --git a/components/modules/scanner/ScannerBlueprintModal.tsx b/components/modules/scanner/ScannerBlueprintModal.tsx index f9e1831..41806d7 100644 --- a/components/modules/scanner/ScannerBlueprintModal.tsx +++ b/components/modules/scanner/ScannerBlueprintModal.tsx @@ -1,5 +1,7 @@ import React from 'react'; import { Settings, X } from 'lucide-react'; +import 'katex/dist/katex.min.css'; +import { BlockMath, InlineMath } from 'react-katex'; interface ScannerBlueprintModalProps { isOpen: boolean; @@ -25,7 +27,7 @@ export default function ScannerBlueprintModal({ isOpen, onClose }: ScannerBluepr return (
-
+
{/* Modal Header */}
@@ -49,30 +51,50 @@ export default function ScannerBlueprintModal({ isOpen, onClose }: ScannerBluepr

Scanner Metrics & Signals

-

Operational details of the anomaly scanner and valuation filters.

+

Operational details of the anomaly scanner, technical velocity thresholds, and valuation overlays.

{/* Core Mechanics */} -
-
+
+

1. 52-Week Drop Mechanics

-

- Filters the stock database for liquid companies trading at significant percentage discounts relative to their 52-week peak. Isolates severe drawdowns caused by asymmetric market overreactions. -

+
+

+ Filters the stock database for liquid companies trading at significant percentage discounts relative to their 52-week peak. The core threshold computes: +

+ +

+ An alert is triggered when the price deviation exceeds a designated threshold (e.g. ), representing a 30% drop from the rolling high. It isolates severe drawdowns caused by asymmetric market overreactions, validating whether the pricing is a statistical dislocation or a permanent valuation impairment. +

+
-
+

2. Welles Wilder RSI-14 Velocity

-

- Uses the smoothed Wilder Relative Strength Index to identify deep oversold thresholds (RSI < 25). Momentum velocity measures standard deviation shocks in the indicator to forecast buy-exhaustion and selloff capitulations. -

+
+

+ Uses the smoothed Welles Wilder Relative Strength Index to identify deep oversold thresholds (RSI ). Wilder smoothing calculations utilize modified EMAs for trend velocity: +

+ + +

+ where and represent upward and downward price changes. Relative Strength is . Momentum velocity measures standard deviation shocks in the indicator to forecast buy-exhaustion and selloff capitulations. +

+
-
+

3. FMP Valuation Overlay

-

- Parses active valuation multiples: Price-to-Earnings (P/E), Price-to-Book (P/B), Dividend Yield, and Price/Earnings-to-Growth (PEG) ratios. Analyzes whether the selloff is justified fundamentally or is a dislocation from value. -

+
+

+ Integrates trailing Price-to-Earnings (P/E), Price-to-Book (P/B), and Dividend Yield (%), alongside the PEG-to-Forward P/E transition. Detail how PEG resolves to a growth rate and computes implicit Forward P/E: +

+ + +

+ When the pricing drop matches these valuation filters, the system triggers a **High-Conviction Value Alert** to signal structural undervaluation rather than a value trap. +

+
diff --git a/components/modules/tech/TechBlueprintModal.tsx b/components/modules/tech/TechBlueprintModal.tsx index 7a9b84b..15f1c31 100644 --- a/components/modules/tech/TechBlueprintModal.tsx +++ b/components/modules/tech/TechBlueprintModal.tsx @@ -1,5 +1,7 @@ import React from 'react'; import { Settings, X } from 'lucide-react'; +import 'katex/dist/katex.min.css'; +import { BlockMath, InlineMath } from 'react-katex'; interface TechBlueprintModalProps { isOpen: boolean; @@ -25,7 +27,7 @@ export default function TechBlueprintModal({ isOpen, onClose }: TechBlueprintMod return (
-
+
{/* Modal Header */}
@@ -49,30 +51,48 @@ export default function TechBlueprintModal({ isOpen, onClose }: TechBlueprintMod

CapEx Cycle & Infrastructure Indicators

-

Operational details of tech overcapacity diagnosis.

+

Operational details of tech overcapacity diagnosis, segment monetization, and supply-chain metrics.

{/* Core Mechanics */} -
-
+
+

1. Monetization Gap & ROI-to-CapEx

-

- Monitors segment revenues (e.g. Azure, AWS, Google Cloud, Meta Family of Apps) against capital spending growth. A negative monetization gap signals segment revenues are growing slower than capital investments. A collapsing ROI-to-CapEx ratio highlights write-down risks. -

+
+

+ Monitors segment revenues (Azure, AWS, Google Cloud, Meta Family of Apps) against capital spending growth. The **Monetization Gap** is defined as the cloud-segment revenue growth percentage minus the absolute CapEx growth percentage: +

+ +

+ A negative monetization gap () signals that cloud revenues are growing slower than capital investments, indicating potential write-down risks. +

+
-
+

2. Supply-Chain Velocity Index

-

- Compares cloud buyers' future purchase obligations (disclosed in notes of 10-Q reports) against Nvidia's spot inventory turnover speeds. A collapsing velocity index indicates buyers are cutting back forward purchase commitments relative to hardware supplier stockpiles. -

+
+

+ Data origins are automated parsers indexing SEC 10-Q filings for forward capital allocations. The **Supply-Chain Velocity Index** maps the buyers' forward purchase commitments against the hardware supplier's (Nvidia) spot inventory: +

+ +

+ This compares forward commitments to the supplier's balance sheet inventory levels to diagnose macro overcapacity and demand corrections 3-6 months in advance. +

+
-
+

3. Cluster Leverage (D/E & CapEx/Dep)

-

- Monitors CapEx-to-depreciation ratios (ratios > 3x indicate hyper-aggressive server capacity additions) alongside Debt-to-Equity changes to assess whether the AI cluster construction is funded by leverage, exposing firms to massive future amortization drag. -

+
+

+ Monitors CapEx-to-depreciation ratios alongside Debt-to-Equity changes: +

+ +

+ Ratios exceeding indicate hyper-aggressive server capacity expansion. When this occurs alongside rising Debt-to-Equity ratios, it indicates that cluster construction is funded by leverage, exposing firms to massive future amortization drag. +

+