So for the past three days I've been trying to figure out getting TA-Lib to work with python. This is the source I compiled into a dylib (mac version of a .so) and have been calling it from a python script coded as follows:
from ctypes import *
import numpy
c_float_p = POINTER(c_float)
data = numpy.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])
data = data.astype(numpy.float32)
data_p = data.ctypes.data_as(c_float_p)
dylib = CDLL('libta_lib.dylib')
value = dylib.TA_S_SMA(c_int(0), c_int(data.size - 1), data_p, 0, 19, data_p)
Printing value returns 2, no matter what the array values are. I cannot change the fourth argument of TA_S_SMA from 0 or 1, or else I get a python 138 error followed by a python crash. Can anyone explain to me the proper way to call this function? My C skills are limited (read 0).
Useful links:
Thanks!