Giter Club home page Giter Club logo

Comments (3)

mrjbq7 avatar mrjbq7 commented on May 21, 2024

I was a little conflicted -- the old way allocated only as much space as was needed to store the results from TA-Lib, which should be fast and exact. On the other hand, the new way makes it easy to integrate TA-Lib with pandas if all arrays share a common index (i.e., are the same length and the lookback period in the beginning is padded with nan), for example:

d = {}
d['MACD'] = talib.MACD(...)
d['EMA'] = talib.EMA(...)
d['RSI'] = talib.RSI(...)

columns = d.keys()
data = np.column_stack([d[key] for key in columns])
df = pandas.DataFrame(data, columns=columns)

If you've got API suggestions, I'm all for it. I could even generate both API's easily enough if there is interest...

from ta-lib-python.

mrjbq7 avatar mrjbq7 commented on May 21, 2024

Also, I forgot the mention:

To get the "lookback" value that was previously returned, you can just find the index of the first non-nan value.

rsi = talib.RSI(...)
lookback = np.where(~np.isnan(rsi))[0][0]

from ta-lib-python.

wilki2021 avatar wilki2021 commented on May 21, 2024

Thanks. In hindsight, I was too quick too submit the question and think you
probably made the right decision. I am only doing some basic plotting with
matplotlib, but after I got the code changed for the new API I actually liked it
better. Thanks for the work to create this - it was very helpful to get ta-lib
easily integrated in Python.


From: John Benediktsson
[email protected]

To: wilki2021 [email protected]
Sent: Sun, July 1, 2012 8:07:08 PM
Subject: Re: [ta-lib] API change rationale? (#3)

I was a little conflicted -- the old way allocated only as much space as was
needed to store the results from TA-Lib, which should be fast and exact. On the
other hand, the new way makes it easy to integrate TA-Lib with pandas if all
arrays share a common index (i.e., are the same length and the lookback period
in the beginning is padded with nan), for example:

d = {}
d['MACD'] = talib.MACD(...)
d['EMA'] = talib.EMA(...)
d['RSI'] = talib.RSI(...)

columns = d.keys()
data = np.column_stack([d[key] for key in columns])
df = pandas.DataFrame(data, columns=columns)

If you've got API suggestions, I'm all for it. I could even generate both API's
easily enough if there is interest...


Reply to this email directly or view it on GitHub:
#3 (comment)

from ta-lib-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.