Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Newbie Question - Security Data

I have scanned through previous posts and didn't find an obvious answer. I have been working with a simple algorithm and continue to get the error "NoTradeDataAvailable:" A specific case is EEM. It seems no matter what timeframe I use I get the same error. Do all Securities have data for all time periods.

5 responses

Hi Michael,

Please see attached. I just modified the template code with:

# TODO: implement your own logic here.  
    order(sid(24705), 50)  

Perhaps you could post your code here?

Grant

There are two SIDs with the symbol EEM

SID     TICKER  START DATE      END DATE  
17845   EEM     1997-11-17      2002-12-05  
24705   EEM     2003-04-11      2013-07-02  

For SID 17845 there is very little data since the earliest date we can use in Quantopian is the start of 2002.

Thanks Grant and Brent. I had clones a Mebane Farber code modified it (see below under Code:). It worked fine with the original equities that were used. I was trying to compare this code to other code in another system so I changed the equities to make the ones being used in the other system. That's when I ran into the error below

ERROR:
NoTradeDataAvailable: {"symbol":"EEM","property":"mavg","algo_time":1371600000000,"first_traded":1010681460000,"sid":17845}
File test_algorithm_sycheck.py:24, in handle_data
File test_algorithm_sycheck.py:24, in
File algoproxy.py:1032, in _transform
File algoproxy.py:1133, in transform

CODE:

http://papers.ssrn.com/sol3/papers.cfm?abstract_id=962461

EEM VNQ VEA DBC VTI BND

def initialize(context):  
    context.secs = [sid(17845),sid(26669),sid(34385),sid(28054),sid(22739),sid(33652)]  
    set_commission(commission.PerTrade(cost=7.95))  
    leverage = 1.0  
    context.weight = leverage/len(context.secs)  
def reweight(context,data,wt,min_pct_diff=0.1):  
    liquidity = context.portfolio.positions_value+context.portfolio.cash  
    orders = {}  
    pct_diff = 0  
    for sec in wt.keys():  
        target = liquidity*wt[sec]/data[sec].price  
        current = context.portfolio.positions[sec].amount  
        orders[sec] = target-current  
        pct_diff += abs(orders[sec]*data[sec].price/liquidity)  
    if pct_diff > min_pct_diff:  
        #log.info(("%s ordering %d" % (sec, target-current)))  
        for sec in orders.keys(): order(sec, orders[sec])

def handle_data(context, data):  
    wt = dict(((sec,(data[sec].mavg(20)>data[sec].mavg(200))*context.weight) for sec in context.secs))  
    reweight(context,data,wt)  

One problem, as Brent said, is that some stocks in your portfolio do not have data for certain dates. Because of this, when you try to use data for those stocks during one of their "dead" dates you get an error. So you just need to make your program deal with that properly. In handle_data, you can detect when an error occurs in a block of code and deal with it. Here, it just tries to add an entry to the dictionary, and if it can't, it ignores the error and moves on.

handle_data(context, data):  
    wt = dict()  
    for sec in context.secs:  
        try:  
            wt[sec] = (data[sec].mavg(20)>data[sec].mavg(200))*context.weight  
        except:  
            pass  
    reweight(context,data,wt)  
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.

Gus, thanks. I will give that a try and post the results. Also realize that if I'm going to us this more I need to learn python.