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:

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).

2 Answers
2

I had the same problem a couple of weeks ago and I found these instructions. Now they're not using ctypes but it works better in my opinion. SWIG will do all the wrapping for you. A Couple of things to watch out for. When you get to the Single:Multi: sections, if you don't know which on, start with the Multi and if that doesn't work go to the single. A little further down you'll see he's replacing Python 2.3 to Python 2.6. I was using python 2.7 and just replaced the 2.6 with 2.7 and it worked. I'm not sure if this will work for higher versions of python but worth a shot if that's what you're using. Hope it helps.