diff --git a/gen/tulipy_gen.pyx b/gen/tulipy_gen.pyx index fd4911b..a8cc4fd 100644 --- a/gen/tulipy_gen.pyx +++ b/gen/tulipy_gen.pyx @@ -77,6 +77,9 @@ TI_BUILD = ti.TI_BUILD class InvalidOptionError(ValueError): pass +class InvalidInputError(ValueError): + pass + cdef dict _type_names = {{ ti.TI_TYPE_OVERLAY: b'overlay', ti.TI_TYPE_INDICATOR: b'indicator', @@ -140,6 +143,12 @@ cdef class _Indicator: cdef np.ndarray[np.float64_t, ndim=1, mode='c'] input_ref for i in range(self.info.inputs): + if inputs[i].dtype == np.float64: + input_ref = inputs[i][-min_input_len:] + elif np.issubdtype(inputs[i].dtype, np.number): + input_ref = inputs[i][-min_input_len:].astype(np.float64) + else: + raise InvalidInputError("Input arrays must have a numeric dtype") input_ref = inputs[i][-min_input_len:] c_inputs[i] = &input_ref[0] diff --git a/setup.py b/setup.py index 4746009..725aeb7 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ description='Financial Technical Analysis Indicator Library. Python bindings for https://github.com/TulipCharts/tulipindicators', long_description=long_description, long_description_content_type='text/markdown', - version='0.3.0', + version='0.3.1', url='https://github.com/cirla/tulipy', author='https://github.com/cirla/tulipy/blob/master/AUTHORS', license='LGPL-3.0', diff --git a/tulipy/__init__.py b/tulipy/__init__.py index 91b9fc0..6e9f798 100644 --- a/tulipy/__init__.py +++ b/tulipy/__init__.py @@ -1107,6 +1107,20 @@ def stoch(high, low, close, pct_k_period, pct_k_slowing_period, pct_d_period): stoch.outputs = [x.decode() for x in lib.stoch.outputs] +def stochrsi(real, period): + """ + Stochastic RSI + """ + + return lib.stochrsi([real], [period]) + +stochrsi.full_name = lib.stochrsi.full_name.decode() +stochrsi.type = lib.stochrsi.type.decode() +stochrsi.inputs = [x.decode() for x in lib.stochrsi.inputs] +stochrsi.options = [x.decode() for x in lib.stochrsi.options] +stochrsi.outputs = [x.decode() for x in lib.stochrsi.outputs] + + def sub(real, real2): """ Vector Subtraction diff --git a/tulipy/lib/__init__.pyx b/tulipy/lib/__init__.pyx index 51bb6b9..0f32a50 100644 --- a/tulipy/lib/__init__.pyx +++ b/tulipy/lib/__init__.pyx @@ -114,6 +114,7 @@ cdef class _Indicator: input_ref = inputs[i][-min_input_len:].astype(np.float64) else: raise InvalidInputError("Input arrays must have a numeric dtype") + input_ref = inputs[i][-min_input_len:] c_inputs[i] = &input_ref[0] cdef ti.TI_REAL * c_outputs[ti.TI_MAXINDPARAMS] @@ -362,80 +363,83 @@ stderr = _Indicator(75) stoch = _Indicator(76) -sub = _Indicator(77) +stochrsi = _Indicator(77) -sum = _Indicator(78) +sub = _Indicator(78) -tan = _Indicator(79) +sum = _Indicator(79) -tanh = _Indicator(80) +tan = _Indicator(80) -tema = _Indicator(81) +tanh = _Indicator(81) -todeg = _Indicator(82) +tema = _Indicator(82) -torad = _Indicator(83) +todeg = _Indicator(83) -tr = _Indicator(84) +torad = _Indicator(84) -trima = _Indicator(85) +tr = _Indicator(85) -trix = _Indicator(86) +trima = _Indicator(86) -trunc = _Indicator(87) +trix = _Indicator(87) -tsf = _Indicator(88) +trunc = _Indicator(88) -typprice = _Indicator(89) +tsf = _Indicator(89) -ultosc = _Indicator(90) +typprice = _Indicator(90) -var = _Indicator(91) +ultosc = _Indicator(91) -vhf = _Indicator(92) +var = _Indicator(92) -vidya = _Indicator(93) +vhf = _Indicator(93) -volatility = _Indicator(94) +vidya = _Indicator(94) -vosc = _Indicator(95) +volatility = _Indicator(95) -vwma = _Indicator(96) +vosc = _Indicator(96) -wad = _Indicator(97) +vwma = _Indicator(97) -wcprice = _Indicator(98) +wad = _Indicator(98) -wilders = _Indicator(99) +wcprice = _Indicator(99) -willr = _Indicator(100) +wilders = _Indicator(100) -wma = _Indicator(101) +willr = _Indicator(101) -zlema = _Indicator(102) +wma = _Indicator(102) + + +zlema = _Indicator(103)