Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
data.can_trade ERROR

I keep getting this error even though I added

data.can_trade(context.assets)

to my code.Why won't this work? Anyone?

Cannot order MVIR on 2016-01-04 14:35:00+00:00 as there is no last price for the security. Try using data.can_trade to check whether an asset is delisted.
There was a runtime error on line 297.

4 responses

i also tried data.can_trade(stock)

Dante,

How did you implement the code? Are you using something like:

for stock in context.assets:  
    if data.can_trade(stock):  
        order(stock, num_shares[stock])  

Yes I am using it like that but with other lines of code so like

for stock in context.assets:
if (stock not in security_lists.leveraged_etf_list) & (prices[stock] > 1.0).all() and data.can_trade(stock):
order(stock, num_shares[stock])

Based on my feeble understanding, that ain't right. You shouldn't see an error. I suggest contacting support, if you haven't already.

I attached some code. Mysteriously, I don't see the error for MVIR. But also, it simply doesn't order MVIR! So, it is confusing.