feat: add ADF (Augmented Dickey-Fuller) indicator

- Core implementation with Cholesky OLS, MacKinnon p-value, AIC lag selection
- Three regression models: NoConstant, Constant, ConstantAndTrend
- NormCdf via Abramowitz & Stegun 7.1.26 erf approximation
- Quantower adapter, Python bridge (NativeAOT export + ctypes + wrapper)
- 69 tests (41 unit + 12 validation + 14 Quantower + 2 consistency)
- Documentation with Schwert table, MacKinnon coefficients, PineScript ref
- All 19,095 tests pass, zero warnings
This commit is contained in:
Miha Kralj
2026-03-15 17:56:54 -07:00
parent 0468283d45
commit e3bd07aa87
17 changed files with 2790 additions and 2 deletions
+14
View File
@@ -8,6 +8,7 @@ from ._helpers import _arr, _ptr, _out, _wrap, _wrap_multi, _check, _lib
__all__ = [
"adf",
"acf",
"geomean",
"granger",
@@ -43,6 +44,19 @@ __all__ = [
]
def adf(close: object, period: int = 50, max_lag: int = 0, regression: int = 1, offset: int = 0, **kwargs) -> object:
"""Augmented Dickey-Fuller test p-value."""
period = int(kwargs.get("length", period))
max_lag = int(max_lag)
regression = int(regression)
offset = int(offset)
src, idx = _arr(close)
n = len(src)
output = _out(n)
_check(_lib.qtl_adf(_ptr(src), _ptr(output), n, period, max_lag, regression))
return _wrap(output, idx, f"ADF_{period}", "statistics", offset)
def acf(close: object, period: int = 14, lag: int = 10, offset: int = 0, **kwargs) -> object:
"""Autocorrelation Function."""
period = int(kwargs.get("length", period))