quantwave
quantwave copied to clipboard
Missing validation: period 0 accepted, negative period gives OverflowError, mismatched H/L/C lengths silently truncated
Found while moving the trade_backtest 9-EMA Bounce backtest onto quantwave 0.9.0 (PyPI wheel, Python 3.12, macOS arm64). Every repro below was rerun and reproduces.
import numpy as np, quantwave as q
q.ema(0, np.arange(1., 6)) # -> [1, 3, 3, 5, 5] (alpha = 2), no error
q.sma(0, np.arange(1., 6)) # -> all NaN, no error
q.ema(-1, np.arange(1., 6)) # OverflowError: can't convert negative int to unsigned
len(q.supertrend(3, 2.0, np.arange(5.), np.arange(4.), np.arange(5.))) # -> 4, no error
Ask:
- Raise
ValueErrorfor period < 1, as documented. - Raise when the high, low and close lengths differ.
Resolved in v0.10.0 (commits 080efe0c and df25c2cf).
- Period Validation: Implemented the
ValidateParamtrait across PyO3 indicator macros, converting periods < 1 (including0and negative values) into descriptiveValueErrors instead of PyO3OverflowErrors. - Length Alignment: All multi-input macros (
ohlc,hl,co,pv,ohlc4,hlcv) validate that input array lengths match, raisingValueErroron length mismatches. - Regression tests verified in
tests/python/test_dogfood_fixes.py::test_gh57_period_validation_raises_value_errorandtest_gh57_mismatched_lengths_raises_value_error.