Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
No Trade Data Available - Minute bar - in the middle of a back test period.

I get the following run time error often when going from daily to minute data.
NoTradeDataAvailable: {"symbol":"AMG","property":"price","algo_time":1325687460000,"first_traded":1009981860000,"sid":17800}
File test_algorithm_sycheck.py:47, in handle_data
File algoproxy.py:272, in getattr

The dailys work. The minute seemed to run fine starting at an earlier time.
If I implement an if then else to only trade at a particular minute bar, say 12.30 the back test works.

So I conclude that there might be one or to minute bars missing for symbols in the middle of backtest period.

How is this to be handled cleanly?

Sarvi

3 responses

Saravanan,

I am working on what may be a related fix with what is returned by the "for" operator on the "data" parameter.

If you don't mind sharing the current algo you are working on, could you attach the failing backtest to this post?
(So that I could check to see if the fix works on your algo.)

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.

Backtest that fails attached

Thanks for giving us the code that's causing the problem.

You're running into a particularly gnarly problem that I've been struggling with making "easy" for you to get around. The problem is that the stock in the error message didn't trade at 9:31 of the first day of your test. In the real world, that happens all the time - stocks open late for all sorts of reasons. If this occurs later in the day (a lull in trading), it's no big deal because the backtester forward-fills the price data. In this case, there is no price in the first bar, and the algorithm has no idea what to do - so it blows up.

What I did to get your algorithm to run is I put in some safety code. Wherever it's checking for prices that might not exist, I make it check, first. I.e.:

            if sym in data:  
                shares = (P.starting_cash * w // data[sym].price)*(1 - context.cash_buffer)  
                order(sym, shares)  

I'm working on ways to make this whole thing more intuitive. Sorry for the problem.

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.