TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.49k stars 1.74k forks source link

Some Pattern Recognition functions don't work correctly #87

Closed ofontaine closed 8 years ago

ofontaine commented 9 years ago

Hi John,

First of all, I'd like to thank you very much for the great work you've done on this wrapper! It has been a tremendous help for me and I'm sure for many many others... So again, THANKS! :-)

I am using TA-Lib in the development of a quantitative technical analysis trading system on the FX market, and have found that some candlesticks functions do not detect their pattern, compared to the outputs of my retail broker's Java platform which uses TA-Lib as well. The following candlesticks give zero arrays as output (no detection at all) on 2007-2014 EURUSD 5min data (more than 750.000 lines) :

CDL3BLACKCROWS CDL3STARSINSOUTH CDL3WHITESOLDIERS CDLADVANCEBLOCK CDLBELTHOLD CDLCLOSINGMARUBOZU CDLCONCEALBABYSWALL CDLDRAGONFLYDOJI CDLGRAVESTONEDOJI CDLHAMMER CDLHANGINGMAN CDLHIGHWAVE CDLHOMINGPIGEON CDLIDENTICAL3CROWS CDLINVERTEDHAMMER CDLKICKING CDLKICKINGBYLENGTH CDLLONGLINE CDLMARUBOZU CDLMATHOLD CDLRISEFALL3METHODS CDLSEPARATINGLINES CDLSHOOTINGSTAR CDLSHORTLINE CDLSPINNINGTOP CDLSTALLEDPATTERN CDLTAKURI CDLTASUKIGAP CDLUNIQUE3RIVER CDLUPSIDEGAP2CROWS

Some of these patterns occur very rarely so might not have a problem, but some very common patterns don't work such as the CDLHAMMER/CDLINVERTEDHAMMER.

Fortunately, a similar problem has been apparently easily fixed on the node-talib library, where it was an initialization issue : https://github.com/oransel/node-talib/issues/12 I hope this will help to find a quick fix...

Thanks very much in advance for your time! Olivier

mrjbq7 commented 9 years ago

Hmm, looks like they maybe fixed it with this commit:

https://github.com/oransel/node-talib/commit/5e1b9d9fba32d8162f54121f784c27bae0a084be

I do try and initialize the library here:

https://github.com/mrjbq7/ta-lib/blob/master/talib/__init__.py#L20

Perhaps it is not working correctly. I will investigate later today, thanks for the report!

Do you have a couple test cases for candle patterns I can use to verify working or not?

Thanks,

ofontaine commented 9 years ago

Great, thanks!

Here are some hammers that just occured (highlighted in blue):

cdlhammer examples

And their price arrays : Open = array([1.13289, 1.13248, 1.13134, 1.13158, 1.13188]) High = array([1.13294, 1.13251, 1.13143, 1.1316, 1.132]) Low = array([1.13255, 1.13218, 1.13114, 1.13132, 1.13168]) Close = array([1.13273, 1.13235, 1.13138, 1.13147, 1.13197])

Outputting : In [1]: talib.CDLHAMMER(Open, High, Low, Close) Out[1]: array([0, 0, 0, 0, 0])

I actually have no idea what to do with this commit... :-S I'm kind of a noob outside of simply writing scripts.

Cheers,

mrjbq7 commented 8 years ago

Should be fixed now, although I want to change how I'm doing things (I hadn't realized each cython module statically links to libta_lib and each requires TA_Initialize). I think I'm going to just make a single cython module but that requires a bit of refactoring which I'll do later in the week.