Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Partial Filled Orders

Hi,

I am getting this warning message in running back tests:

"2011-03-01 WARN Your order for 7065 shares of XIV has been partially filled. 3416 shares were successfully purchased. 3649 shares were not filled by the end of day and were canceled."

I am using "order_target_percent(sid,0)" to sell all the positions. Since this is a market order, not a limit order, how could the order not get filled for the whole day?

By the way the platform is fantastic. I realized this partial order feature makes back tests much more realistic for securities with small trading volume. My guess is the API has some liquidity assumption built-in to determine which order can be filled and which cannot.

Cheers,
Bo

5 responses

Hi Bo,

In backtesting we have a default slippage model which limits the number of shares that you can buy or sell during a period to 1/40 of the volume of that equity during that period. You can read about the slippage model here. It applies equally to market orders, limit orders, and all other orders.

The purpose of the model is to simulate the difficulty of filling orders in the real world; it can be difficult to fill orders in low-volume equities, and it's not usually possible to capture a large fraction of an equity's volume. However, if you would prefer that the slippage model be less harsh, it's possible to make it more lenient or disable it completely using the set_slippage function, also documented at the link above.

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.

But the problem is that I place market orders one minute after market opens in the morning, and I am only limiting myself to Q500US equities, with a capital of 1,000,000, how come I still see a lot of partially filled orders by the end of day if I run full backtest and look at "Log Output"? With such a moderate among of capital split evenly among 20 stocks, I won't be able to fill market orders for the whole day even if I am only limiting myself to Q500US? And many stocks were completely unfilled for the whole day, not even one share. Does this make sense? I just hope the Q500US is a dynamic set of US equities that changes with time and represents the most liquid 500 stocks at the prevailing time. If that is the case, how come I can't even fill one share of some of its constituent stocks during the whole day? I already change the set_slippage function from 2.5% to 10%. This totally baffles me and frustrates me. I hope somebody can enlighten me here.

Here is a glimpse of the output from "Log Output":

2009-08-10 16:00 WARN Your order for -4420 shares of SGN has been partially filled. 200 shares were successfully sold. 4220 shares were not filled by the end of day and were canceled.
2009-08-10 16:00 WARN Your order for 504 shares of DWMT failed to fill by the end of day and was canceled.
2009-08-10 16:00 WARN Your order for -3540 shares of SPO failed to fill by the end of day and was canceled.
2009-08-11 16:00 WARN Your order for 1106 shares of ELU failed to fill by the end of day and was canceled.
2009-08-11 16:00 WARN Your order for -4294 shares of SBA failed to fill by the end of day and was canceled.
2009-08-11 16:00 WARN Your order for -4245 shares of SGN has been partially filled. 1000 shares were successfully sold. 3245 shares were not filled by the end of day and were canceled.
2009-08-11 16:00 WARN Your order for 473 shares of DWMT failed to fill by the end of day and was canceled.
2009-08-11 16:00 WARN Your order for -60 shares of MAO failed to fill by the end of day and was canceled.
2009-08-11 16:00 WARN Your order for 20 shares of MKF failed to fill by the end of day and was canceled.
2009-08-11 16:00 WARN Your order for -3569 shares of SPO has been partially filled. 238 shares were successfully sold. 3331 shares were not filled by the end of day and were canceled.
2009-08-11 16:00 WARN Your order for -8189 shares of CMFO has been partially filled. 6039 shares were successfully sold. 2150 shares were not filled by the end of day and were canceled.
2009-08-12 16:00 WARN Your order for 1106 shares of ELU failed to fill by the end of day and was canceled.
2009-08-12 16:00 WARN Your order for -4300 shares of SBA has been partially filled. 240 shares were successfully sold. 4060 shares were not filled by the end of day and were canceled.
2009-08-12 16:00 WARN Your order for -3270 shares of SGN failed to fill by the end of day and was canceled.
2009-08-12 16:00 WARN Your order for 465 shares of DWMT has been partially filled. 100 shares were successfully purchased. 365 shares were not filled by the end of day and were canceled.
2009-08-12 16:00 WARN Your order for -3391 shares of SPO failed to fill by the end of day and was canceled.
2009-08-12 16:00 WARN Your order for -70 shares of MAO failed to fill by the end of day and was canceled.
2009-08-13 16:00 WARN Your order for 1106 shares of ELU failed to fill by the end of day and was canceled.
2009-08-13 16:00 WARN Your order for 240 shares of SBA failed to fill by the end of day and was canceled.
2009-08-13 16:00 WARN Your order for 1200 shares of SGN failed to fill by the end of day and was canceled.
2009-08-13 16:00 WARN Your order for 291 shares of DWMT failed to fill by the end of day and was canceled.
2009-08-13 16:00 WARN Your order for -3510 shares of SPO failed to fill by the end of day and was canceled.

Yeah I've noticed this too on most Algo's doesn't make much sense for instruments that trade millions of shares a day, 3,000 shares weren't filled by end of day, with 50,000,000 shares......

Nathan Wolfe, this doesn't make any sense for market orders. They cannot be partially filled, unless you exhaust the whole book, which, unless you trade millions of dollars, is not possible. By partially filling these orders you make backtesting completely invalid.

No Egor, you can override the slippage model and order all available shares if you like, however that won't play in the real world very well, so then you can tailor the slippage model to your liking. I think the default is designed in part for what they would like to see in the fund.