Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Need help: Your order for xxx shares of xxx failed to fill by the end of day and was canceled

On the 2007-01-03, I always get the error message "Your order for xxx shares of xxx failed to fill by the end of day and was canceled."
It's not only for this backtest, but for all other backtests that I tested.
2007-01-03 always fail to make a purchase.

Can someone please advise how to solve this?

Thank you.

6 responses

Maybe a y2k-ish bug that's only being seen in the IDE because today is January 1? That's perhaps overdramatizing but ...
See if different tomorrow.

I added this line:

    for x in sec:  
        if not data.can_trade(x): print x

Looks like first trading day of each year but note the time

2007-01-02 03:31  PRINT Equity(24 [AAPL])  
2007-01-02 03:31  PRINT Equity(16841 [AMZN])  
2007-01-02 03:31  PRINT Equity(23112 [CVX])  
2007-01-02 14:00 WARN Your order for 235 shares of AAPL failed to fill by the end of day and was canceled.  
2007-01-02 14:00 WARN Your order for 760 shares of AMZN failed to fill by the end of day and was canceled.  
2007-01-02 14:00 WARN Your order for 680 shares of CVX failed to fill by the end of day and was canceled.  
2008-01-02 03:31  PRINT Equity(24 [AAPL])  
2008-01-02 03:31  PRINT Equity(16841 [AMZN])  
2008-01-02 03:31  PRINT Equity(23112 [CVX])  
2009-01-02 03:31  PRINT Equity(24 [AAPL])  
2009-01-02 03:31  PRINT Equity(16841 [AMZN])  
2009-01-02 03:31  PRINT Equity(23112 [CVX])  
2010-01-04 03:31  PRINT Equity(24 [AAPL])  
2010-01-04 03:31  PRINT Equity(16841 [AMZN])  
2010-01-04 03:31  PRINT Equity(23112 [CVX])  
2011-01-03 03:31  PRINT Equity(24 [AAPL])  
2011-01-03 03:31  PRINT Equity(16841 [AMZN])  
2011-01-03 03:31  PRINT Equity(23112 [CVX])  
2012-01-03 03:31  PRINT Equity(24 [AAPL])  
2012-01-03 03:31  PRINT Equity(16841 [AMZN])  
2012-01-03 03:31  PRINT Equity(23112 [CVX])  
2013-01-02 03:31  PRINT Equity(24 [AAPL])  
2013-01-02 03:31  PRINT Equity(16841 [AMZN])  
2013-01-02 03:31  PRINT Equity(23112 [CVX])  
2014-01-02 03:31  PRINT Equity(24 [AAPL])  
2014-01-02 03:31  PRINT Equity(16841 [AMZN])  
2014-01-02 03:31  PRINT Equity(23112 [CVX])  
2015-01-02 03:31  PRINT Equity(24 [AAPL])  
2015-01-02 03:31  PRINT Equity(16841 [AMZN])  
2015-01-02 03:31  PRINT Equity(23112 [CVX])  
2016-01-04 03:31  PRINT Equity(24 [AAPL])  
2016-01-04 03:31  PRINT Equity(16841 [AMZN])  
2016-01-04 03:31  PRINT Equity(23112 [CVX])  
2017-01-03 03:31  PRINT Equity(24 [AAPL])  
2017-01-03 03:31  PRINT Equity(16841 [AMZN])  
2017-01-03 03:31  PRINT Equity(23112 [CVX])  
End of logs.  

.
For me in the Pacific time zone that would normally be a time of 06:31 for market open, not 03:31.

If there's anything to my theory we could give it a catchy name: The New Year's Day Time Bug
Happy New Year everybody.

Haha....so lets call it the New Year Bug :P
Happy New Year !!!

But if this happens every year, why is the orders failing and canceled only in 2007?

Is there any way we can prevent this? This issue is giving inaccurate backtest result.

Hi Leon,

On January 2, 2007, the US equity market was closed in observance of National Day of Mourning for former President Ford. From what I can tell, the US futures market were still trading on that day. The backtest you ran was on the US Futures calendar, so Jan. 2, 2007 isn't labeled as a holiday, but the US stocks that are traded by your algorithm had no volume on that day. If you change your backtest to run on the US Equity calendar (recommended if you're not trading futures), the day will be treated like any other holiday.

Let me know if you have any other questions.

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.

Hi Jamie,

Thank you for the clarification.

Is there any command that I can use to automatically purchase securities at the next available trading day?

Thank you.

Hi Leon,

Unfortunately there is no such function. You'll have to place your orders again the next day.

I've been ignoring futures and didn't notice that in the calendar.