Back to Community
Can't fill a single order of the most liquid future contract?

The first lines in the log show that a single order couldn't be filled the entire day. Does anyone know why this happens?

2007-01-02 12:30 my_rebalance:18 INFO Future(1016200703 [SYH07])  
2007-01-02 22:00 WARN Your order for 1 shares of SYH07 failed to fill by the end of day and was canceled.  
Clone Algorithm
6
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 59ece5813467a63ffe663c2e
There was a runtime error.
11 responses

It seems to have something to do with US holidays. This years fails for fillings are dates after holidays.

2017-01-17 00:00 WARN Your order for 1 shares of SYH17 failed to fill by the end of day and was canceled. Is right after Martin Luther King, Jr. Day, which was 16th of January.

2017-02-21 00:00 WARN Your order for 1 shares of SYH17 failed to fill by the end of day and was canceled. Is day after Washington's Birthday also known as Presidents' Day, which was 20th of February.

2017-05-30 00:00 WARN Your order for 1 shares of SYN17 failed to fill by the end of day and was canceled. Is the day after Memorial Day which was May 29th.

And so on.

Strange, Mikko. I see the WARNs on holiday dates.

2017-01-16 22:00 WARN Your order for 1 shares of SYH17 failed to fill by the end of day and was canceled.  
2017-02-20 22:00 WARN Your order for 1 shares of SYH17 failed to fill by the end of day and was canceled.  
2017-05-29 22:00 WARN Your order for 1 shares of SYN17 failed to fill by the end of day and was canceled.  

This might be a front-end adjustment that quantopian is doing in order to display time in our own respective timezones. Notice that our WARNs differ by two hours. Are you two hours ahead of London, Mikko? :-)

But ok, you cracked it. Apparently quantopian's got a problem with the calendar and doesn't know about some holidays.

Actually I am two hours ahead of London time.

Hmm... If a person from US would run this algorithm would they get correct dates?

That's what I'm guessing. But the specific hour when the WARN happens is just front-end. The orders should fill that day, regardless of where you are located, of course.

Market for soybean seems to be closed for those days. I played around with timing of rebalance function, just to see if it would cause WARN on market early close of 12:05 on July 3rd, which show as 4th in my end, and it did:

2017-07-04 00:00 WARN Your order for 1 shares of SYQ17 failed to fill by the end of day and was canceled.
2017-07-05 00:00 WARN Your order for 1 shares of SYQ17 failed to fill by the end of day and was canceled.

Hey Mikko, this isn't the whole story, I think.

I went and looked at volumes on those days. If it's true that the correct explanation is that those days were trading days but quantopian simply isn't aware of them, you would still expect to see zero trading volume on those days, right?

That is what you get for 2017-01-16 but not 2007-01-02.

So why is it that in 2007-01-02 we get a "can't fill" even though there was plenty of volume that day?

Code:

data = history(  
    continuous_future('SY', adjustment='mul', roll='volume'),  
    fields = ['price','volume','contract'],  
    frequency = 'daily',  
    start = '2007-01-02',  
    end = '2008-01-01'  
)
data.head()  

Hey João,

Which source did you used for volume for date 2007-01-02? Weren't markets closed because US was mourning passing of President Ford?

http://money.cnn.com/2007/01/01/markets/newyears_closures/index.htm

I don't know what to tell you Mikko. But please run the notebook code that I've copy pasted in the previous post, and you'll see that the volume for SYH07 is not zero. Am I missing something?

Hi Joao,

One thing to remember is that Quantopian provides 24hr pricing and volume data for futures contracts, but algorithms can only trade contracts between 6:30am and 5pm ET.

For the particular date you are looking at, most of SYH07 trading volume falls outside this tradable window, see the notebook attached. So while the volume is non-zero, it is still not enough to fill an order based on the slippage model. You can read more on the futures slippage model here.

I hope this helps.

EDIT*: I made a mistake when slicing the DataFrame. The dataset's timestamps are in UTC, so tradable_hours should be data['2007-01-02 10:31:00+00:00':'2007-01-02 21:00:00+00:00']

Loading notebook preview...
Notebook previews are currently unavailable.
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.

Ernesto, thanks for coming back.

So Mikko was right in that the explanation is that that date was a holiday, but some trading still happened, apparently, but mostly out of regular hours. Strange.

João, that's correct. In addition, the holiday schedule with US futures is a bit more complicated than that of US equities. Different futures exchanges and even different futures can have their own holiday schedules. As a result, the only official holidays that the backtester is aware of for 'US futures' are US New Years, Good Friday, and Christmas, as these are common in all US futures markets. You can see the code for this in Zipline. Unfortunately, other holidays will demonstrate the behavior that you noticed, with 0 volume fills. At some point, we'd like to improve that UX.

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.