Back to Community
New feature: TA-Lib support

Hi everyone,

We're pleased to announce that Quantopian now support a large subset of TA-Lib methods! TA-Lib is a collection of very useful financial analysis functions.

To learn more and to see the methods we support, here's the documentation: https://www.quantopian.com/help#api-talib

Attached is a simple example algorithm that uses the Relative Strength Indicator (RSI) to signal buys and sells.

If you need a TA-Lib method that we don't support, let us know. All other feedback is welcome as well.

thanks,
Jean

Clone Algorithm
240
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 51e468aec5177d06cbd6be37
This backtest was created using an older version of the backtester. Please re-run this backtest to see results using the latest backtester. Learn more about the recent changes.
There was a runtime error.
Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

13 responses

That's awesome! Really excited about this!

Great news!

Does this mean that we no longer need to install ta-lib separately when using zipline?

@Alex: For zipline standalone you still have to install ta-lib as a dependency. There are wrappers in transforms.ta however.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

How is TA-Lib intended to work, for daily vs. minutely data. The help page says:

Daily vs minute data

Quantopian's TA-Lib methods respect the data frequency in your backtest or live algorithm. If you're backtesting with daily data, then all the time periods are calculated in days. If you're backtesting or live trading with minute data, all the time periods are in minutes.

This suggests that the time base units are days for daily data, and minutes for minutely data. However, I found that to obtain a 14 day RSI in minute mode, I had to use rsi = ta.RSI(timeperiod=14) and not rsi = ta.RSI(timeperiod=5460). Wouldn't it make sense to provide minute-level resolution when the backtest is run on minute data? Or perhaps in minute mode, fractional trading days can be entered for timeperiod (rounded to the nearest minute internally)?

Cheers,

Grant

Hi Grant,

Yes, you're correct. This will actually be addressed by our refactoring of the batchtransform that allows you specify window length at the minute-resolution.

Thomas

Thanks Thomas,

Seems to be a bug, by the way. TA-Lib RSI does not seem to accept multiples of 390...strange. See https://www.quantopian.com/posts/ma-cross-over-w-slash-rsi.

Another question regarding TA-Lib...do the methods (e.g. RSI) take into account datetime (actual calendar time) or just tics (trading time, either days or minutes)? As I understand, the RSI uses exponentially weighted averages, so I'm wondering if the weighting is based on calendar time or trading time (no gaps)?

Grant

Grant: To my knowledge it only uses bars to count time, not actual time. Certainly that is an issue and also something that should be addressed by the grand refactoring ;).

Hi guys,

Some feedback on TA-Lib:

  1. It'd be helpful to have more complete technical documentation on the implementation. When I click the "learn more" links on the Quantopian help page (e.g. http://tadoc.org/indicator/RSI.htm), I just get more links, rather than a definitive technical description of the function that Quantopian uses.
  2. Support for feeding data directly to TA-Lib functions would be useful, since this seems to be the way to handle the "multiple timeframes" issue. Peter Cawthron has provided some examples, but you might consider putting up some formal documentation and an example on your help page.
  3. To follow up on my question above, I've gathered that TA-Lib assumes continuous, equi-spaced time series data as an input (i.e. it basically ignores datetime stamps). Is this a correct assumption? How could it be validated?

Thanks,

Grant

Hello Grant,

An observation on 3. above - the TA-Lib functions just work on arrays which in our case are usually within a DataFrame or a BarData object but I know nothing about the latter.

import talib

import numpy as np

a = np.array([1.0,2,3,4,5])

talib.MA(a, 3)  
Out[26]: array([ nan,  nan,   2.,   3.,   4.])

If you don't have iPython installed you should have! See: http://ipython.org/

P.

I like the talib from Quantopian very much since it is powerful and user friendly. Since Q will close the live-trading, I have to look for another alternative. I use now the Anaconda 3-4.4 (Python 3.6.x) . As I try to install the ta-lib from Q, it failt. It seems the ta-lib is not supported by Python 3.6?

Or, how can I compile the ta-lib from Q for Python 3.6?

Thomas

@Guy

Thanks for the reply. I have also googled out the same solution and fixed the problem yesterday. It ssems the whole world use the same solution. :-)