Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Weird runtime error with order_target_percent

Hi

Backtester throws a run-time error when I place order for MCO (Moody's Corporation) on 29th September 2014.
I place order for a variety of securities in a loop (like always).
Also, If before placing the order I put a check, it works without an error. I am puzzled. Has anybody observed this before?

Thanks
Shiv

1.  
order_target_percent(sid, 1) ....(throws error when it's MCO)

2.  
if sid is symbol('MCO'):  
    log.info(sid)  
order_target_percent(sid, 1) .... (this works)  
3 responses

Try checking if MCO is in the data object. See https://www.quantopian.com/help#overview-checkingdata. Just a hunch. What is the exact error?

Thanks Grant!! That worked!

Good. It is basically a rule that you should always check that data exists before using a security key. The problem is that is not always done in posted examples. If you look at Delaney's example, https://www.quantopian.com/posts/quantopian-lecture-series-long-short-equity-algorithm, you'll see that he applies the check.