Skip to content

$ cat methodology.md

Technical foundations of the Rebel Terminal analysis engine.

Conformal Prediction

// PLAIN ENGLISH

Instead of giving you a single number ("BTC will be at $70k"), we give you a range ("BTC will be between $58k and $82k") with a statistical guarantee on how often that range is correct. If we say 90% coverage, the true value lands inside the interval at least 90% of the time on future data.

// TECHNICAL DETAIL

Conformal prediction is a distribution-free framework for constructing prediction sets with finite-sample coverage guarantees. Given a calibration set {(X_i, Y_i)}_{i=1}^n and a new test point X_{n+1}, the conformal prediction set C(X_{n+1}) satisfies P(Y_{n+1} ∈ C(X_{n+1})) ≥ 1 - α under the exchangeability assumption. No parametric distributional assumptions are required. We implement three conformal methods: StandardCP (split conformal with quantile-based thresholds), MondrianCP (group-conditional coverage for regime-stratified data), and CQR (Conformalized Quantile Regression for heteroscedastic intervals).

P(Y_{n+1} ∈ C(X_{n+1})) ≥ 1 - α
// REFERENCES

[1] Vovk, V., Gammerman, A., & Shafer, G. (2005). Algorithmic Learning in a Random World. Springer.

[2] Romano, Y., Patterson, E., & Candès, E. (2019). "Conformalized Quantile Regression." NeurIPS.

[3] Barber, R.F., Candès, E.J., Ramdas, A., & Tibshirani, R.J. (2021). "Predictive Inference with the Jackknife+." Annals of Statistics.

Coverage Methods

// PLAIN ENGLISH

We use three different methods depending on the data type. StandardCP works for most cases. MondrianCP gives separate coverage for each market regime (expansion vs contraction). CQR handles cases where uncertainty varies — wider intervals when volatility is high, tighter when it's calm.

// TECHNICAL DETAIL

StandardCP: Split conformal with nonconformity scores s_i = |Y_i - μ̂(X_i)| for regression or 1 - π̂_y(X_i) for classification. The prediction set includes all labels y where the score is below the (1-α)(1+1/n) quantile of calibration scores. MondrianCP: Group-conditional conformal that partitions the calibration set by regime labels (EXPANSION/CONTRACTION/TRANSITION) and computes per-group thresholds. Provides coverage guarantees within each group, not just marginally. CQR: Trains quantile regressors at levels α/2 and 1-α/2, then conformally calibrates the residuals to guarantee finite-sample coverage, producing intervals that adapt to local variance.

// REFERENCES

[1] Mondrian Conformal Predictors: Vovk, V. (2013). "Conditional Validity of Inductive Conformal Predictors." JMLR Workshop.

[2] CQR: Romano, Y., Patterson, E., & Candès, E. (2019). NeurIPS.

Hamilton Filter (Detrending)

// PLAIN ENGLISH

Economic data has long-term trends that obscure cyclical patterns. The Hamilton filter removes the trend using a regression-based approach, leaving behind the cyclical signal we care about — the liquidity cycle. Unlike the popular HP filter, it doesn't create artificial cycles at the endpoints of the data.

// TECHNICAL DETAIL

The Hamilton filter regresses Y_t on Y_{t-h} (typically h=24 months) to extract the cyclical component as the residual: ε_t = Y_t - β̂₀ - β̂₁Y_{t-h}. This avoids the spurious cycle artifacts and endpoint instability of the Hodrick-Prescott filter. The residuals preserve the spectral properties of the underlying cyclical dynamics without introducing phase shifts.

ε_t = Y_t - β̂₀ - β̂₁·Y_{t-h}
// REFERENCES

[1] Hamilton, J.D. (2018). "Why You Should Never Use the Hodrick-Prescott Filter." Review of Economics and Statistics, 100(5), 831-843.

Lomb-Scargle Periodogram (Cycle Detection)

// PLAIN ENGLISH

After detrending, we need to find the dominant cycle frequency — how long does a full liquidity cycle take? The Lomb-Scargle method detects periodic patterns even when data points aren't evenly spaced (common with economic data). It tells us the cycle length, where we are in it (peak, trough, recovery, contraction), and how confident we should be in that classification.

// TECHNICAL DETAIL

The Lomb-Scargle periodogram estimates spectral power P(ω) at angular frequency ω from unevenly sampled data. We apply it to Hamilton-filtered residuals to identify the dominant cycle frequency. The fitted sinusoid f(t) = A·sin(ωt + φ) parameterizes the cycle position into four quadrants: TROUGH (φ ∈ [π, 3π/2)), RECOVERY (φ ∈ [3π/2, 2π)), PEAK (φ ∈ [0, π/2)), CONTRACTION (φ ∈ [π/2, π)). R² of the sinusoidal fit quantifies cycle regularity.

P(ω) = (1/2){[Σ(Y_i - Ȳ)cos(ω(t_i - τ))]² / Σcos²(ω(t_i - τ)) + [Σ(Y_i - Ȳ)sin(ω(t_i - τ))]² / Σsin²(ω(t_i - τ))}
// REFERENCES

[1] Lomb, N.R. (1976). "Least-squares frequency analysis of unequally spaced data." Astrophysics and Space Science, 39, 447-462.

[2] Scargle, J.D. (1982). "Studies in astronomical time series analysis." Astrophysical Journal, 263, 835-853.

Net Supply-Demand (Net S-D)

// PLAIN ENGLISH

Net S-D answers one question: is there more liquidity entering the system (bullish) or leaving it (bearish)? We take supply indicators (Fed balance sheet, M2 money supply, bank reserves) and subtract demand indicators (Treasury issuance, reverse repo absorption). The result is a single number — positive means liquidity is expanding, negative means it's tightening.

// TECHNICAL DETAIL

Net S-D is a composite z-score: z(supply) - z(demand). Supply components (e.g., Fed total assets, M2, bank reserves) are individually z-scored over a trailing window and averaged. Demand components (e.g., Treasury general account, RRP facility balance) are similarly z-scored, optionally sign-inverted, and averaged. The composite is computed monthly from 1998–present. Year-over-year changes in Net S-D drive regime classification: sustained positive ΔNet S-D → EXPANSION, sustained negative → CONTRACTION, ambiguous → TRANSITION.

// REFERENCES

[1] Howell, M. (2020). Capital Wars: The Rise of Global Liquidity. Springer.

Regime Detection

// PLAIN ENGLISH

Markets operate in three states: expansion (liquidity growing, risk assets rising), contraction (liquidity shrinking, risk assets falling), and transition (mixed signals, regime is changing). We detect the current regime from Net S-D changes and historical patterns. Since 2006, we've identified 98 regime transitions with clear patterns in how BTC and other assets behave in each state.

// TECHNICAL DETAIL

Regime labels are assigned based on year-over-year ΔNet S-D with hysteresis thresholds to prevent chattering. The classification uses a 3-state model: EXPANSION (ΔNet S-D > +σ for ≥3 consecutive months), CONTRACTION (ΔNet S-D < -σ for ≥3 consecutive months), TRANSITION (otherwise). MondrianCP leverages these regime labels for group-conditional conformal inference, providing coverage guarantees stratified by market state. Regime durations range from 4 to 36 months historically.

// REFERENCES

[1] Hamilton, J.D. (1989). "A New Approach to the Economic Analysis of Nonstationary Time Series." Econometrica, 57(2), 357-384.

Backtesting Protocol

// PLAIN ENGLISH

We don't just test our models on the data they were trained on — that would be cheating. We use temporal cross-validation: train on past data, predict the future, measure how often our intervals contain the true value. We enforce a strict rule that training data never overlaps with test data chronologically, mimicking real-world deployment. Our coverage target is 87.5% (the midpoint of our 85-90% acceptance band).

// TECHNICAL DETAIL

Temporal cross-validation with purged groups: fold boundaries are determined by time-sorted indices with a gap buffer equal to the forecast horizon. Within each fold, the model is trained on data before the purge boundary and evaluated on data after it. Coverage is measured as the fraction of test points whose true value falls within the conformal prediction set. We target 87.5% coverage (α=0.125) with an acceptance band of [85%, 90%]. Slots are classified as ON_TARGET (85-90%), OVERCOVERING (>90%), or UNDERCOVERING (<85%).

// REFERENCES

[1] de Prado, M.L. (2018). Advances in Financial Machine Learning. Wiley. (Chapter 7: Cross-Validation in Finance)

[2] Arlot, S. & Celisse, A. (2010). "A survey of cross-validation procedures for model selection." Statistics Surveys, 4, 40-79.

Why Macro Matters for Active Traders

// PLAIN ENGLISH

Day traders and swing traders often dismiss macro data as "too slow." But macro regime detection acts as a directional filter — in expansion regimes, long setups historically have a 68% hit rate vs 47% in contraction. The VIX z-score provides a real-time risk management overlay. Net S-D trend gives directional bias. You don't need to trade the macro signal directly — use it to size positions, filter entries, and manage risk.

// TECHNICAL DETAIL

Macro regime context improves intraday alpha through three mechanisms: (1) Directional bias: BTC 12-month returns average +127% in EXPANSION vs -31% in CONTRACTION regimes since 2015, providing a statistical prior for trade direction. (2) Volatility regime: VIX z-score > 1.5 correlates with 2.3x average true range expansion, affecting position sizing and stop placement. (3) Correlation regime: Cross-asset correlations shift significantly between regimes (BTC-SPX correlation: +0.62 in contraction vs +0.21 in expansion), affecting portfolio hedging and pair trades.

Data Sources & Freshness

// PLAIN ENGLISH

We ingest 281 time series from the Federal Reserve Economic Data (FRED) database, covering liquidity, inflation, credit, equities, commodities, and FX. Market data (BTC, ETH, S&P 500, VIX, Gold, DXY) comes from Yahoo Finance. Data is refreshed daily, with FRED series updating on their native schedule (daily, weekly, monthly, or quarterly depending on the series). All series are available from 1998 onward.

// TECHNICAL DETAIL

FRED API ingestion covers 281 series across 6 categories: Liquidity (47 series), Inflation (31), Credit (28), Equity (42), Commodities (35), FX (19). Each series retains full history. Market data from Yahoo Finance covers 8 core assets at daily resolution. Derived features include z-scores (trailing 36-month window), year-over-year changes, Hamilton-filtered residuals, and Lomb-Scargle cycle parameters. Feature engineering produces ~40 derived features per series. Total feature space: ~11,240 features before selection.

Last updated: March 2026. Methodology evolves with each pipeline iteration.
Questions? See the glossary or API docs.

[REBELTERMINAL]~/methodology>type anywhere to navigate · Press ` or Cmd+J to open