DRT Feature Engine: Core Mathematical Specification

This document details the exact mathematical formulas, timing index derivations, and clustering logic used by the shared feature engine for strict train/serve parity.

1. Initial Balance (IB) & Defining Range (DR / IDR)

The Initial Balance covers the first 12 5-minute bars (1 hour) of each session.

2. V-Shape 3-Leg Trajectory Encoding

Quantifies the path dynamics within the IB window across 3 directional segments:

$$vs\_leg1 = \frac{extreme_1 - dr\_open}{idr\_range}$$ $$vs\_leg2 = \frac{extreme_2 - extreme_1}{idr\_range}$$ $$vs\_leg3 = \frac{dr\_close - extreme_2}{idr\_range}$$ $$vs\_ix = \frac{\text{bar\_index}(extreme_1)}{N_{bars}}$$ $$vs\_shape = \frac{vs\_leg1 \cdot vs\_leg3}{\max(|vs\_leg2|, 0.01)}$$

3. Price Map Clustering (5 Centroids)

Clusters all 48 price levels (open, high, low, close across 12 IB bars) against 5 fixed structural price anchors:

$$C = \{ c_0: dr\_open, \; c_1: dr\_close, \; c_2: idr\_high, \; c_3: idr\_mid, \; c_4: idr\_low \}$$

Each level \( p \in \{O, H, L, C\} \) is assigned to the nearest centroid \(\arg\min_j |p - c_j|\):

$$ib\_hl\_concentration = \frac{count(c_2) - count(c_4)}{N_{levels}}$$ $$ib\_oc\_concentration = \frac{count(c_0) - count(c_1)}{N_{levels}}$$ $$ib\_mid\_concentration = \frac{count(c_3)}{N_{levels}}$$ $$ib\_price\_map = \arg\max_j count(c_j)$$

4. Expansion Window Timing Indices

Normalized temporal progress \([0.0, 1.0]\) anchored to session boundaries and breakout events:

5. Price Action Model (PAM) 9-Class Classification

ClassTypeCondition
M2_xxxNo Breakout\(br = 0\) or \(\text{NaN}\) (No confirmed close outside DR)
M1_baaClean BreakoutBreakout confirmed, BHLOD formed, ABR peak reached, AHLOD formed, no failures
M1_xaaEarly Peak BreakoutBreakout without prior BHLOD, ABR peak reached, AHLOD formed
M1_baxBreakout TrendingBHLOD formed, ongoing new peak (AHLOD not yet set)
M0_faaType 1 Failed BreakoutDR Failure 1 occurred before peak reversal
M0_xafType 2 Failed BreakoutDR Failure 2 occurred following peak extension without prior BHLOD
M0_faxType 1 Immediate FailDR Failure 1 without subsequent AHLOD
M0_fafCompound FailureBoth DR Fail 1 and Fail 2 triggered
M0_bafType 2 Failure with BHLODBHLOD formed, then post-peak failure