bt.talib pattern recognition returns 0.0 always
dmonn last edited by
First of all huge kudos to building this framework. I've been using it for half a year or so for my crypto trading and it really does anything I wish for. Searching through this forum has always delivered awesome optimizations and things to look out for, thanks for that.
I just pulled in
ta-libfor the first time last week according to Indicators - ta-lib. Installed
pip install ta-lib, pulled in the binary via Homebrew and got started.
I was confused when the patterns always returned 0.0 for me. My setup has been pretty battle tested and I'm confident my data pipelines are OK – nevertheless I created a minimal example where I can verify that behaviour on every pattern recognizer.
import backtrader as bt class TALibStrategy(bt.Strategy): def __init__(self): self.pattern = bt.talib.CDLDOJI(self.data.open, self.data.high, self.data.low, self.data.close) def next(self): print(self.pattern) def runstrat(): cerebro = bt.Cerebro() data0 = bt.feeds.GenericCSVData(dataname='./btc_usdt_1h.csv', datetime=0, high=1, low=2, open=3, close=4, volume=5, openinterest=-1) cerebro.adddata(data0) cerebro.addstrategy(TALibStrategy) cerebro.run() if __name__ == '__main__': runstrat()
All the outputs are 0.0 – now I have a few ideas why this could happen but I might need help to verify them:
My data is trash. I don't think so because it's directly grabbed from ccxt (crypto) or bought from known historical data providers (forex), used for testing extensively and has been plotted and verified numerous times. Nevertheless, somebody could grab this sample and plug in their own data. If it works, my fault. I can also provide my data.
My local ta-lib binary is broken. Possible! I am on Mac and directly installed via
brew install ta-lib. Tried this out on a new Linux box and saw same behaviour. I followed the normal installation instructions though. If they don't work, might need some documentation.
The bt <-> talib integration is broken. I'm on
22.214.171.124. Hard for me to verify.
There are actually no patterns. Don't think so? Tried this with ~5 classifiers on EURUSD and BTCUSD data, tried 1min, 5min, 15min and 1h patterns for up to 5 years back. Surely there is a pattern somewhere?
Happy to help here and provide any info, data, codes, outputs!
dmonn last edited by
Ping? Anybody able to try this?
run-out last edited by
@dmonn Your code is working for me on one minute data.