Skip to content

02 Feature Engineering Pipeline

ElMoorish edited this page Sep 12, 2026 · 1 revision

πŸ“Š 02. Feature Engineering Pipeline

The TriDomainMoE feature engineering suite is implemented in src/features/tri_domain_features.py to ensure 100% strict mathematical parity between offline historical training, vectorized backtesting, and sub-20ms live MT5 execution.


1. Technical Domain Features (6D)

Index Feature Symbol Mathematical Formulation Economic Rationale
0 log_ret $\ln(C_t / C_{t-1})$ Instantaneous bar return
1 vol_20 $\text{Std}(\text{log_ret}, N=20)$ Short-term realized volatility baseline
2 fracdiff $(1 - B)^d C_t, \quad d^*=0.45$ Stationarity preserving continuous long-memory price action
3 vol_mom $V_t / \text{SMA}(V, 20) - 1.0$ Surge volume above rolling equilibrium
4 parkinson_ratio $\sigma_{\text{parkinson}} / \sigma_{\text{close}}$ Distinguishes wick fakeouts from authentic directional expansion
5 bar_ofi $CLV_t \times \text{vol_mom}_t$ Bar-level Order Flow Imbalance proxy ($CLV = \frac{(C - L) - (H - C)}{H - L}$)

1.1 Fractional Differencing ($d^* = 0.45$)

Integer differencing ($d=1.0$) strips all historical memory, creating an unlearnable white-noise series. We apply fractional differencing via the binomial series expansion:

$$(1 - B)^d = \sum_{k=0}^{\infty} (-1)^k \binom{d}{k} B^k = 1 - d B + \frac{d(d-1)}{2!} B^2 - \dots$$

Using the Augmented Dickey-Fuller (ADF) test, $d^* = 0.45$ achieves stationarity ($p < 0.01$) while retaining over $90%$ of price level correlation.

1.2 Parkinson Volatility Ratio

Using intraday High and Low bounds, the Parkinson volatility estimator is:

$$\sigma_{\text{parkinson}} = \sqrt{\frac{1}{4 \ln 2 \cdot N} \sum_{i=1}^N \left(\ln \frac{H_i}{L_i}\right)^2}$$

When $\sigma_{\text{parkinson}} / \sigma_{\text{close}} \gg 1.0$, market activity consists of volatile whipsaws rather than trend momentum, prompting defensive position sizing.


2. Macro Term Structure Domain Features (6D)

Index Feature Symbol Mathematical Formulation Economic Rationale
0 h1_log_ret $\ln(C_{H1, t} / C_{H1, t-1})$ Higher-timeframe macro drift
1 h1_trend_50 $(C_{H1} - \text{EMA}{50}) / \text{ATR}{14}$ Macro trend persistence relative to average true range
2 h1_vol_24h $\text{Std}(r_{H1}, 24) \times \sqrt{24 \times 365}$ 24-hour annualized historical crypto volatility
3 h4_trend_200 $(C_{H1} - \text{EMA}{200}) / \text{ATR}{14}$ Multi-day swing regime anchor
4 d1_trend_600 $(C_{H1} - \text{EMA}{600}) / \text{ATR}{14}$ Secular macro regime anchor (institutional bias)
5 vol_term_slope $\sigma_{24\text{h}} / \sigma_{168\text{h}}$ Term structure curve (short vs weekly volatility expansion)

3. Fundamental Crypto Sentiment Domain Features (8D)

Index Feature Symbol Mathematical Formulation Economic Rationale
0 polarity $\in [-1.0, +1.0]$ Net directional sentiment across crypto news releases
1 uncertainty $\in [0.0, 1.0]$ Entropy / ambiguity score in institutional reportage
2 monetary_score $\in [-1.0, +1.0]$ Central bank liquidity expectations (Fed / DXY correlation)
3 geopolitics $\in [0.0, 1.0]$ Geopolitical risk and safe-haven rotation intensity
4 corporate_flow $\in [-1.0, +1.0]$ Institutional crypto treasury and ETF net flows
5 commodities $\in [-1.0, +1.0]$ Cross-asset commodity / energy inflation pressures
6 cvd_flow_24h $\sum_{t=1}^{288} \text{OFI}_t$ Continuous 24h rolling Cumulative Volume Delta (CVD)
7 spread_basis_ratio $\text{Spread}_t / \text{ATR}_t$ Real-time liquidity friction relative to available price volatility

4. Microstructure Order Flow Imbalance (OFI) & VPIN

From tick-level trade streams, Volume-Synchronized OFI calculates the net pressure on the bid and ask queues:

$$\text{OFI}_k = \sum_{t \in \text{Bar}_k} \Delta Q_{\text{bid}, t} - \Delta Q_{\text{ask}, t}$$

Volume-Synchronized Probability of Toxicity (VPIN) tracks informed order dumping:

$$\text{VPIN} = \frac{\sum_{\tau=1}^V |V_\tau^B - V_\tau^S|}{V \cdot N}$$

When $\text{VPIN} > 0.65$, adverse selection risk spikes; the system automatically triggers the Pre-Trade Anti-Adverse Book Shield, refusing toxic incoming orders.

🧠 TriDomainMoE Wiki


🌐 Ecosystem & Portals


πŸ’– Research Grants (USDT)

  • Asset: USDT (Tether)
  • Network: TRON (TRC20)
  • Address:
    TC8TFkemSFGEeBPF5ZQKbmjK97FVEGwrwc

Clone this wiki locally