TulipCharts / tulipy

[NOT ACTIVELY MAINTAINED] Tulipy - Financial Technical Analysis Indicator Library (Python bindings for Tulip Charts)
https://github.com/TulipCharts/tulipindicators
GNU Lesser General Public License v3.0
330 stars 83 forks source link

Integer options #8

Closed codeplea closed 7 years ago

codeplea commented 7 years ago

Passing integers as options doesn't work:

>>> ti.sma(close, 5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tulipy\__init__.py", line 1021, in sma
    return lib.sma([real], [period])
  File "tulipy\lib\__init__.pyx", line 68, in tulipy.lib._Indicator.__call__ (tulipy/lib\__init__.c:2731)
    cdef np.ndarray[np.float64_t, ndim=1, mode='c'] c_options = np.array(option_list)
ValueError: Buffer dtype mismatch, expected 'float64_t' but got 'long'

>>> ti.sma(close, 5.0)
array([...])

This is the common use-case, so we shouldn't need to type the extra ..

cirla commented 7 years ago

Good catch. I think this should be a one line fix. I'll put up a PR later this evening.

cirla commented 7 years ago

I'm on mobile at the moment but I believe just changing this line:

 cdef np.ndarray[np.float64_t, ndim=1, mode='c'] c_options = np.array(option_list)

to this:

 cdef np.ndarray[np.float64_t, ndim=1, mode='c'] c_options = np.array(option_list, dtype=np.float64)

should do the trick.