HilbertPhasor

Incremental, causal technical analysis documentation

Summary

HilbertPhasor is RTTA's streaming Hilbert in-phase and quadrature components, porting TA-Lib HT_PHASOR. Together they form a complex analytic signal of the detrended, smoothed price used inside the dominant-cycle estimator.

Update API

result = rtta.HilbertPhasor(fillna=True).update(value)
Parameter Default Meaning
fillna True If False, NaN until lookback of 32 samples is exceeded

update(...) returns a result with:

advance(value) updates state; last() returns the cached result.

Theory Of Operation

The Hilbert transform produces a \(90^\circ\) phase-shifted companion of a real signal. Ehlers / TA-Lib apply a short FIR-style Hilbert operator to a 4-bar WMA of price (the detrender), then take:

The complex pair \((I,Q)\) feeds the homodyne discriminator that estimates dominant period. Plotting \(I\) vs \(Q\) traces a phasor diagram of the local cycle.

Recurrence

Shared front end with other Hilbert indicators (see HilbertDominantCyclePeriod):

\[S_t = \frac{4 x_t + 3 x_{t-1} + 2 x_{t-2} + x_{t-3}}{10}\]
\[\lambda_t = 0.075\, P_{t-1} + 0.54\]

Let \(D_t\) be the adaptive Hilbert detrender of \(S_t\), and \(Q1_t\) the adaptive Hilbert transform of \(D_t\). With bar parity alternating odd/even filter banks:

\[I_t = D_{t-3}^{\text{(parity path)}},\qquad Q_t = Q1_t\]

In code after each update:

\[\texttt{inphase} = I_t,\qquad \texttt{quadrature} = Q_t\]

With fillna=False, both fields are NaN until more than 32 samples have been processed.

Implementation Notes

Reference