Back to Community
How can I get daily indicator in minutely mode of backtesting and live trading?

I would really like to know if there is a systematic way to get daily indicators in minutely mode.
As my most strategies are for day trading, daily indicator will be extremely important and necessary for backtesting and live trading.
However, TA-Lib methods have the same period as the test in which they are used, which means it is not plausible to directly use them in live trading and backtesting (both under minutely mode).

I have searched many posts on Quantopian and just found few helpful posts. Some posts concerning RSI and ATR has to construct them by some specific functions.
It seems to get daily indicators in minutely mode, one has to construct them case by case, which I do not think very efficient.

I wonder if anyone could please share some thoughts about this issue. Thanks.

6 responses


If you import TA-Lib it will use whatever you pass it as input which can be daily data from the 'history' function. The attached is fairly meaningless but shows the idea.


Clone Algorithm
Total Returns
Max Drawdown
Benchmark Returns
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
import talib

def initialize(context):
    context.stock = sid(2)

def handle_data(context, data):
    prices = history(20, '1d', 'close_price')
    minimum = talib.MIN(prices[context.stock], timeperiod=20)
    maximum = talib.MAX(prices[context.stock], timeperiod=20)
    record(Price=data[context.stock].close_price, Min=minimum[-1], Max=maximum[-1])                 
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.

Thanks. It is a good answer.

But if I switch to daily backtesting mode, history method is no longer working and I have to change the price variable to the ordinary one.
I wonder if there is an one-work-for-all solution to this problem no matter which mode it is like in Multichart.

My guess is probably not, but just wish it maybe exist in Quantopian.

Hi Eric,
I faced the same problem that you are raising. I do not have a solution... what I am doing is the following: I switched to zipline for backtesting (if we work with daily data there are no problems in term of availability of historical data), and for the live test and trading I go with the TWS java API.
This obviously doubles the coding effort (python+zipline, then TWS AAPI+java), but there are a few reasons:
using zipline on my PC I do not have the limitations of the Quantopian IDE, that I find too heavy (namely:
- logs dramatically slow and possibly incomplete (this is the worst thing, as makes very difficult not only the debugging but also the checks on the correctness of the results);
- python with some functionalities not available and not interactive (a dead python, indeed);
- very limited editing functionalities (find and replace, control of the indentation are missing...);
- ...)
I edit the zipline based code with ipython notebook: it is very fast and fully interactive, the unrestricted logs allow an efficient debugging and testing, there are no restictions to the python functionalities.
Yes, there is the recoding to java when moving from the backtests to live test/trading. But this is done only for the algos that are worthy this step ( one out of 10 or more, for me).
In conclusion: many thanks to Quantopian for giving us zipline; for the IDE in my view there still is a lot of work to do (and maybe some rethinking of the design).

@ Leo,

I'm basically thinking along the same lines, having used Quantopian for a long time. A more efficient, flexible way of doing R&D is needed (by me, at least, since I don't have the intuition nor an already-proven algorithm). Where do you get your offline data?


From yahoo. I used to get the data daily from, then aggregate them in a mysql database. But this approach requires additional work to handle the splits... with yahoo the problem is already solved, and both python and zipline connect very easily to yahoo.

You can use history with ta-lib for daily indicators, take a look at this example:

One possible point of confusion is that Quantopian has its own ta-lib wrapper. You can use, for example, "ta.ATR" without importing Python's ta-lib module. However, this only runs on certain transformations and is powered by batch_transform. In the future we'd like to optimize this wrapper to integrate with all ta-lib functions and run on history(). Instead of using our built-in ta-lib wrapper, you can directly import Python's ta-lib module and use it like in the example above.

We're making progress! If you're looking for keyboard shortcut tips in the IDE, take a look here. But we're glad that you're finding Zipline useful.


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.