diff --git a/DEV_LOG.md b/DEV_LOG.md index 89359be..0287813 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -107,5 +107,18 @@ This document tracks all modifications, npm packages, active compilation states, * **Active Bugs**: None. * **Type Checker Status**: Verified clean compilation (`npx tsc --noEmit` returns exit code 0). +--- +## [2026-06-13] - Crypto Bayes Mathematical Refactoring (#ISSUE-013) +### Added +* **Mathematical Specifications & Integration Proof**: Expanded [CryptoMathModal.tsx](file:///c:/Users/jannr/.gemini/antigravity/scratch/investment-sandbox/components/modules/crypto/CryptoMathModal.tsx) with a detailed Section D on the 4-feature client-side Random Forest, Section E on the conjugate Beta-Binomial update, and Section F with the formal calculus integration proof and expanded operational formula. +* **UI Status Badge**: Mounted a static glowing amber status badge `🟡 SYSTEM-AUTARK (OFFLINE-CORE)` in the header of [CryptoDemo.tsx](file:///c:/Users/jannr/.gemini/antigravity/scratch/investment-sandbox/components/modules/crypto/CryptoDemo.tsx) to confirm the module runs 100% locally with zero external API calls. + +### Modified +* **KaTeX Escaping Repairs**: Fixed string escaping anomalies by double-escaping LaTeX backslashes across [CryptoMathModal.tsx](file:///c:/Users/jannr/.gemini/antigravity/scratch/investment-sandbox/components/modules/crypto/CryptoMathModal.tsx) to eliminate runtime KaTeX rendering corruption. +* **`QUANT_ROADMAP.md`**: Synchronized quantitative system specifications under Section 4.V. + +### Active Bugs / Compile Status +* **Active Bugs**: None. +* **Type Checker Status**: Verified clean compilation (`npx tsc --noEmit` returns exit code 0). diff --git a/QUANT_ROADMAP.md b/QUANT_ROADMAP.md index ed99000..67dcaef 100644 --- a/QUANT_ROADMAP.md +++ b/QUANT_ROADMAP.md @@ -166,6 +166,37 @@ Where: --- +### V. Crypto Bayesian Markov & Self-Correcting Engine + +Integrates a two-stage predictive mapping pipeline for cryptocurrency assets (BTC, ETH, SOL) that combines on-chain derivatives data with online Bayesian updates. + +#### 1. Machine Learning Random Forest Classifier +Ensemble of 10 decision trees mapping four features to forecast trend probabilities: +* **Funding Rates (FR)**: Future leverage balance indicators. +* **Open Interest (OI) Volatility**: Contract buildup velocities. +* **Long/Short (LS) Retail Skew**: Sentiment extreme markers. +* **Whale Inflows (W)**: Cold-wallet transfer proxy metrics. + +$$P_{\text{ML}} = \frac{1}{M} \sum_{m=1}^{M} T_m(FR_t, OI_t, LS_t, W_t)$$ + +#### 2. Conjugate Beta-Binomial Update +Continuous ML probability outputs ($P_{\text{ML}}$) are mapped into a discrete Binomial likelihood by defining the Trust-Weight Hyperparameter ($w=12$) as the Effective Sample Size (ESS): +* **Prior distribution**: $\theta \sim \text{Beta}(\alpha_{\text{prior}}, \beta_{\text{prior}})$ +* **Binomial Likelihood pseudo-observations**: $k = P_{\text{ML}} \times w$ (successes), $w - k = (1 - P_{\text{ML}}) \times w$ (failures) +* **Conjugate Posterior Update**: + $$\alpha_{\text{post}} = \alpha_{\text{prior}} + k$$ + $$\beta_{\text{post}} = \beta_{\text{prior}} + (w - k)$$ + +#### 3. Posterior Mean Integration Proof +Integrating the continuous parameter $\theta$ out of the posterior distribution gives the mathematical expectation of the posterior: +$$\mathbb{E}[\theta \mid \text{Data}] = \int_{0}^{1} \theta \cdot P(\theta \mid \text{Data}) \, d\theta = \int_{0}^{1} \theta \cdot \frac{\theta^{\alpha_{\text{post}}-1}(1-\theta)^{\beta_{\text{post}}-1}}{\text{B}(\alpha_{\text{post}}, \beta_{\text{post}})} \, d\theta$$ +$$\mathbb{E}[\theta \mid \text{Data}] = \frac{\text{B}(\alpha_{\text{post}} + 1, \beta_{\text{post}})}{\text{B}(\alpha_{\text{post}}, \beta_{\text{post}})} = \frac{\alpha_{\text{post}}}{\alpha_{\text{post}} + \beta_{\text{post}}}$$ + +#### 4. Expanded Workstation Formula +$$P_{\text{Posterior}} = \frac{\alpha_{\text{prior}} + (P_{\text{ML}} \times w)}{\alpha_{\text{prior}} + \beta_{\text{prior}} + w}$$ + +--- + ## 5. Multi-Regime Transition Classifier The core cognitive brain of the sandbox dynamically adjusts allocation weights across our portfolio modules based on estimated macroeconomic and market states. diff --git a/components/modules/crypto/CryptoDemo.tsx b/components/modules/crypto/CryptoDemo.tsx index c0f7449..ecf53dd 100644 --- a/components/modules/crypto/CryptoDemo.tsx +++ b/components/modules/crypto/CryptoDemo.tsx @@ -185,6 +185,11 @@ export default function CryptoDemo() {
+ + + SYSTEM-AUTARK (OFFLINE-CORE) + +
{/* Modal Body */} -
-
-
-

4. Crypto Bayesian Markov Engine

-

Models momentum regimes and updates transition probabilities using on-chain alpha inputs.

-
+
+ +
+

4. Crypto Bayesian Markov Engine

+

Models momentum regimes and updates transition probabilities using on-chain alpha inputs.

+
-
-

A. Markov Chain State Space

-

- The asset return state space is mapped into 3 momentum regimes: -

-
-
- State 1 (S1) - Bearish Squeeze / Crackdown -
-
- State 2 (S2) - Consolidation / Mean Reversion -
-
- State 3 (S3) - Parabolic Bull Run -
+ {/* Section A: Markov Chain State Space */} +
+

A. Markov Chain State Space

+

+ The asset return state space is mapped into 3 momentum regimes: +

+
+
+ State 1 (S1) + Bearish Squeeze / Crackdown
-
- -
-

B. Transition Matrix (P)

-

- Calculates transition probabilities over rolling 90-day return vectors: -

-
- -

- where represents the frequency probability of moving from State i to State j. -

+
+ State 2 (S2) + Consolidation / Mean Reversion
-
- -
-

C. Bayesian Update Engine

-

- When external alpha inputs (e.g. Funding Rate anomalies, Whale inflows) occur, state probabilities are updated using Bayes' theorem: -

-
- -

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

+
+ State 3 (S3) + Parabolic Bull Run
+ + {/* Section B: Transition Matrix (P) */} +
+

B. Transition Matrix (P)

+

+ Calculates transition probabilities over rolling 90-day return vectors: +

+
+ +

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

+
+
+ + {/* Section C: Bayesian Update Engine */} +
+

C. Bayesian Update Engine

+

+ When external alpha inputs (e.g. Funding Rate anomalies, Whale inflows) occur, state probabilities are updated using Bayes' theorem: +

+
+ +

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

+
+
+ + {/* Section D: Two-Stage Hybrid Machine Learning Pipeline */} +
+

D. Two-Stage Hybrid Machine Learning Pipeline

+

+ To minimize false signals and adapt to changing momentum regimes, we run a two-stage hybrid ML pipeline. First, a client-side Random Forest Classifier maps non-linear combinations of four features to forecast trend probabilities: +

+
+ Ensemble Feature Inputs: +
    +
  • Funding Rates (\\(FR_t\\)): Measures leverage imbalance in futures contracts.
  • +
  • Open Interest Volatility (\\(OI_t\\)): Captures the contract buildup speed.
  • +
  • Long/Short Retail Skew (\\(LS_t\\)): Identifies retail sentiment extremes.
  • +
  • Whale Accumulation Inflows (\\(W_t\\)): Proxy for cold-wallet transfer velocities.
  • +
+

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

+ +
+
+ + {/* Section E: Conjugate Beta-Binomial Error-Correction Engine */} +
+

E. Conjugate Beta-Binomial Error-Correction Engine

+

+ Raw ML forecasts are susceptible to regime drift. We implement a self-correcting Beta-Binomial update. The continuous probability output from the Random Forest model is mapped into a discrete Binomial likelihood by defining the Trust-Weight Hyperparameter () as the Effective Sample Size (ESS): +

+
+
+

1. Prior Distribution (Accuracy History):

+ +

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

+
+ +
+

3. Conjugate Posterior Update:

+ +
+
+
+ + {/* Section F: Mathematical Proof of Posterior Mean Integration */} +
+

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: +

+
+

Posterior Expectation Integral Proof:

+ +

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

+
+
+