Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Does Trade data sometimes go missing?

I have an algo I've been using to learn with and have run a complete backtest on without a problem. For some reason, now, when I try and run the build or full backtest I get a "No Trade Date Available" Error:

NoTradeDataAvailable: {"symbol":"JKS","property":"price","algo_time":1370525460000,"first_traded":1273847460000,"sid":39635}

From 2013-06-06 to 2014-01-13 running in minute mode.

Looking at JKS it clearly goes back farther than 2013-06-06 so what's going on?

2 responses

Hi Pumplerod,

It's very common for stocks not to trade in a given minute, even when they have a long trade history. In general, you won't encounter this problem because we forward-fill the information using the last recorded price. However, this will throw an error if the first trade bar is illiquid and contains no data.

Did you perhaps change your start date on the backtest? Most likely the first bar is illiquid on your first date.

Below is a piece of code that will protect you from errors in missing data.

for sid in context.portfolio.positions:  
        if sid in data:  
            price = data[sid].price  

If your error still lingers, is it possible for you to share your algo or example code that shows the problem? I'd be happy to take a look so that we can further debug!

Alisa

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.

Hello Pumplerod,

You might also consider if you want to ignore filled bars. Example code for this is:

    for stock in context.stocks:  
        if data[stock].datetime < get_datetime():  
            return  

It works since the routine forward-fills both the OHLCV trade data and the datetime stamp.

I've attached some code that may be of interest. See the log output.

Also, note that you can toggle the forward filling on/off with both the batch transform and the history methods.

Grant