Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How is the order filled

I realized that in my backtest, order is filled very slowly even though the stock has enough liquidity. I attached a small testing program below which uses AKAM as an example. I try to buy 200 share of AKAM on Jun 30, 2017 12:30 pm, but it is not filled completely after 15 min. If you check yahoo finance, the volume is more than 20k every 15 min. So how come 200 share takes that long? Could someone please advise how the order is filled in the backtest? Thanks

2 responses

Your order for 200 shares (actually 201 shares) is filled completely in 6 minutes by 11:37. All those shares are then sold in 7 minutes beginning at 11:46. This can be seen in the transaction details tab for the backtest. This is the behavior when using the default slippage model in backtesting. It uses VolumeShareSlippage and sets the volume_limit = .025 (ie 2.5%) . What this means is that the max shares filled in any given bar will never be more than 2.5% of the actual shares traded (ie the volume) for that bar. Your order gets spread out over as many bars as needed to fill the entire order quantity. You can override this behavior by setting different values or a different model if you wish. See the documentation https://www.quantopian.com/help#ide-slippage . You may also be interested in this post https://blog.quantopian.com/accurate-slippage-model-comparing-real-simulated-transaction-costs/

You noted that Yahoo listed 20,000 shares every 15 minutes. This makes sense. 2.5% of 20,000 is 400. Your order for half that (201 shares) would fill in about half that time. About 7 minutes. Which it did.

Got it. Thanks Dan.