mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-28 09:47:43 +00:00
ce654ca670
New indicators: - HWC (Holt-Winters Channel) — channels, 27 tests - VWMACD (Volume-Weighted MACD) — momentum, 38 tests - Squeeze Pro — oscillators, 69 tests - BW_MFI (Bill Williams MFI) — oscillators - DSTOCH (Double Stochastic) — oscillators - ATRSTOP (ATR Trailing Stop) — reversals - VSTOP (Volatility Stop) — reversals - Convexity (Beta Convexity) — statistics, 23 tests Integration: - Python bridge: Exports.cs, _bridge.py, wrapper modules - Documentation: _sidebar.md, _index.md pages, SPEC.md - All analyzer warnings fixed (MA0074, xUnit2013, S2699) Build: 0 warnings, 0 errors | Tests: 15,933 passed, 0 failed
202 lines
7.9 KiB
Python
202 lines
7.9 KiB
Python
"""quantalib reversals indicators.
|
|
|
|
Auto-generated — DO NOT EDIT.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from ._helpers import _arr, _ptr, _out, _wrap, _wrap_multi, _check, _lib
|
|
|
|
|
|
__all__ = [
|
|
"atrstop",
|
|
"chandelier",
|
|
"ckstop",
|
|
"fractals",
|
|
"pivot",
|
|
"pivotcam",
|
|
"pivotdem",
|
|
"pivotext",
|
|
"pivotfib",
|
|
"pivotwood",
|
|
"sar",
|
|
"sarext",
|
|
"swings",
|
|
"ttm_scalper",
|
|
"vstop",
|
|
]
|
|
|
|
|
|
def atrstop(high: object, low: object, close: object, period: int = 21, multiplier: float = 3.0, offset: int = 0, **kwargs) -> object:
|
|
"""ATR Trailing Stop."""
|
|
period = int(kwargs.get("length", period))
|
|
multiplier = float(multiplier)
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(h)
|
|
output = _out(n)
|
|
_check(_lib.qtl_atrstop(_ptr(h), _ptr(l), _ptr(c), _ptr(output), n, period, multiplier))
|
|
return _wrap(output, idx, f"ATRSTOP_{period}", "reversals", offset)
|
|
|
|
|
|
def chandelier(open: object, high: object, low: object, close: object, period: int = 14, multiplier: float = 2.0, offset: int = 0, **kwargs) -> object:
|
|
"""Chandelier Exit."""
|
|
period = int(kwargs.get("length", period))
|
|
multiplier = float(multiplier)
|
|
offset = int(offset)
|
|
o, idx = _arr(open); h, _ = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(o)
|
|
output = _out(n)
|
|
_check(_lib.qtl_chandelier(_ptr(o), _ptr(h), _ptr(l), _ptr(c), _ptr(output), n, period, multiplier))
|
|
return _wrap(output, idx, f"CHANDELIER_{period}", "reversals", offset)
|
|
|
|
|
|
def ckstop(open: object, high: object, low: object, close: object, atrPeriod: int = 22, multiplier: float = 2.0, stopPeriod: int = 3, offset: int = 0, **kwargs) -> object:
|
|
"""Chuck LeBeau Stop."""
|
|
atrPeriod = int(atrPeriod)
|
|
multiplier = float(multiplier)
|
|
stopPeriod = int(stopPeriod)
|
|
offset = int(offset)
|
|
o, idx = _arr(open); h, _ = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(o)
|
|
output = _out(n)
|
|
_check(_lib.qtl_ckstop(_ptr(o), _ptr(h), _ptr(l), _ptr(c), _ptr(output), n, atrPeriod, multiplier, stopPeriod))
|
|
return _wrap(output, idx, f"CKSTOP_{atrPeriod}", "reversals", offset)
|
|
|
|
|
|
def fractals(high: object, low: object, offset: int = 0, **kwargs) -> object:
|
|
"""Williams Fractals."""
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low)
|
|
n = len(h)
|
|
upOutput = _out(n)
|
|
downOutput = _out(n)
|
|
_check(_lib.qtl_fractals(_ptr(h), _ptr(l), _ptr(upOutput), _ptr(downOutput), n))
|
|
return _wrap_multi({"upOutput": upOutput, "downOutput": downOutput}, idx, "reversals", offset)
|
|
|
|
|
|
def pivot(high: object, low: object, close: object, offset: int = 0, **kwargs) -> object:
|
|
"""Pivot Points (Traditional)."""
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(h)
|
|
ppOutput = _out(n)
|
|
_check(_lib.qtl_pivot(_ptr(h), _ptr(l), _ptr(c), _ptr(ppOutput), n))
|
|
return _wrap(ppOutput, idx, "PIVOT", "reversals", offset)
|
|
|
|
|
|
def pivotcam(high: object, low: object, close: object, offset: int = 0, **kwargs) -> object:
|
|
"""Camarilla Pivot Points."""
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(h)
|
|
ppOutput = _out(n)
|
|
_check(_lib.qtl_pivotcam(_ptr(h), _ptr(l), _ptr(c), _ptr(ppOutput), n))
|
|
return _wrap(ppOutput, idx, "PIVOTCAM", "reversals", offset)
|
|
|
|
|
|
def pivotdem(open: object, high: object, low: object, close: object, offset: int = 0, **kwargs) -> object:
|
|
"""DeMark Pivot Points."""
|
|
offset = int(offset)
|
|
o, idx = _arr(open); h, _ = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(o)
|
|
ppOutput = _out(n)
|
|
_check(_lib.qtl_pivotdem(_ptr(o), _ptr(h), _ptr(l), _ptr(c), _ptr(ppOutput), n))
|
|
return _wrap(ppOutput, idx, "PIVOTDEM", "reversals", offset)
|
|
|
|
|
|
def pivotext(high: object, low: object, close: object, offset: int = 0, **kwargs) -> object:
|
|
"""Extended Pivot Points."""
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(h)
|
|
ppOutput = _out(n)
|
|
_check(_lib.qtl_pivotext(_ptr(h), _ptr(l), _ptr(c), _ptr(ppOutput), n))
|
|
return _wrap(ppOutput, idx, "PIVOTEXT", "reversals", offset)
|
|
|
|
|
|
def pivotfib(high: object, low: object, close: object, offset: int = 0, **kwargs) -> object:
|
|
"""Fibonacci Pivot Points."""
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(h)
|
|
ppOutput = _out(n)
|
|
_check(_lib.qtl_pivotfib(_ptr(h), _ptr(l), _ptr(c), _ptr(ppOutput), n))
|
|
return _wrap(ppOutput, idx, "PIVOTFIB", "reversals", offset)
|
|
|
|
|
|
def pivotwood(high: object, low: object, close: object, offset: int = 0, **kwargs) -> object:
|
|
"""Woodie Pivot Points."""
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(h)
|
|
ppOutput = _out(n)
|
|
_check(_lib.qtl_pivotwood(_ptr(h), _ptr(l), _ptr(c), _ptr(ppOutput), n))
|
|
return _wrap(ppOutput, idx, "PIVOTWOOD", "reversals", offset)
|
|
|
|
|
|
def sar(open: object, high: object, low: object, close: object, afStart: float = 0.02, afIncrement: float = 0.02, afMax: float = 0.2, offset: int = 0, **kwargs) -> object:
|
|
"""Parabolic SAR."""
|
|
afStart = float(afStart)
|
|
afIncrement = float(afIncrement)
|
|
afMax = float(afMax)
|
|
offset = int(offset)
|
|
o, idx = _arr(open); h, _ = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(o)
|
|
output = _out(n)
|
|
_check(_lib.qtl_sar(_ptr(o), _ptr(h), _ptr(l), _ptr(c), _ptr(output), n, afStart, afIncrement, afMax))
|
|
return _wrap(output, idx, "SAR", "reversals", offset)
|
|
|
|
|
|
def sarext(open: object, high: object, low: object, close: object, startValue: float = 0.0, offsetOnReverse: float = 0.0, afInitLong: float = 0.02, afLong: float = 0.02, afMaxLong: float = 0.2, afInitShort: float = 0.02, afShort: float = 0.02, afMaxShort: float = 0.2, offset: int = 0, **kwargs) -> object:
|
|
"""Parabolic SAR Extended."""
|
|
startValue = float(startValue)
|
|
offsetOnReverse = float(offsetOnReverse)
|
|
afInitLong = float(afInitLong)
|
|
afLong = float(afLong)
|
|
afMaxLong = float(afMaxLong)
|
|
afInitShort = float(afInitShort)
|
|
afShort = float(afShort)
|
|
afMaxShort = float(afMaxShort)
|
|
offset = int(offset)
|
|
o, idx = _arr(open); h, _ = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(o)
|
|
output = _out(n)
|
|
_check(_lib.qtl_sarext(_ptr(o), _ptr(h), _ptr(l), _ptr(c), _ptr(output), n, startValue, offsetOnReverse, afInitLong, afLong, afMaxLong, afInitShort, afShort, afMaxShort))
|
|
return _wrap(output, idx, "SAREXT", "reversals", offset)
|
|
|
|
|
|
def swings(high: object, low: object, lookback: int = 5, offset: int = 0, **kwargs) -> object:
|
|
"""Swing High/Low."""
|
|
lookback = int(lookback)
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low)
|
|
n = len(h)
|
|
highOutput = _out(n)
|
|
lowOutput = _out(n)
|
|
_check(_lib.qtl_swings(_ptr(h), _ptr(l), _ptr(highOutput), _ptr(lowOutput), n, lookback))
|
|
return _wrap_multi({"highOutput": highOutput, "lowOutput": lowOutput}, idx, "reversals", offset)
|
|
|
|
|
|
def ttm_scalper(high: object, low: object, close: object, useCloses: int = 0, offset: int = 0, **kwargs) -> object:
|
|
"""TTM Scalper."""
|
|
useCloses = int(useCloses)
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(h)
|
|
highOutput = _out(n)
|
|
lowOutput = _out(n)
|
|
_check(_lib.qtl_ttmscalper(_ptr(h), _ptr(l), _ptr(c), _ptr(highOutput), _ptr(lowOutput), n, useCloses))
|
|
return _wrap_multi({"highOutput": highOutput, "lowOutput": lowOutput}, idx, "reversals", offset)
|
|
|
|
|
|
def vstop(high: object, low: object, close: object, period: int = 7, multiplier: float = 3.0, offset: int = 0, **kwargs) -> object:
|
|
"""Volatility Stop."""
|
|
period = int(kwargs.get("length", period))
|
|
multiplier = float(multiplier)
|
|
offset = int(offset)
|
|
h, idx = _arr(high); l, _ = _arr(low); c, _ = _arr(close)
|
|
n = len(h)
|
|
output = _out(n)
|
|
_check(_lib.qtl_vstop(_ptr(h), _ptr(l), _ptr(c), _ptr(output), n, period, multiplier))
|
|
return _wrap(output, idx, f"VSTOP_{period}", "reversals", offset)
|