Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Order execution - why aren't orders executed immediately in the full order_value quantity?

Hello All,

I'm new to Quantopian and trying to figure out how order execution works.

I have a statement in my code that says:
"order_value(sec, 1000)"

Let's say the current price of the security is $10
My expectation is that this will send an order to buy 100 shares of the security.

However, what I find in the logs is, something like:
Fill: 32 shares of SPZ at $10.05 on 2016-11-11 10:41:00
Fill: 47 shares of SPZ at $10.05 on 2016-11-11 10:42:00
Fill: 10 shares of SPZ at $10.05 on 2016-11-11 10:43:00

My questions:
1. How can force an order quantity of 100 to be executed immediately? In a day trading scenario, it is often critical that I get immediate execution
2. If that's not possible, what's the logic used behind splitting the order into 3 or more parts? At least I can plan better..

Please help!

Thank you,
Jimmy

2 responses

Jimmy,

The backtesting engine looks at your trade then applies a "slippage" function to guess at how many shares you could have actually traded. Take a look at the documentation https://www.quantopian.com/help#ide-slippage .

The default slippage uses the VolumeShareSlippage model and limits the number of shares purchased per minute to 2.5% of the actual. You can easily change the max volume by calling the set_slippage function in the initialize method. Setting volume_limit to 1.00 will allow you to purchase 100% of the minute bar volume.

Using VolumeShareSlippage you can never trade more than the actual traded per minute. However, if you use FixedSlippage in your set_slippage function then the backtester will trade all of your shares in a minute regardless of actual volume. The price however will be impacted which you can take a guess at and customize by setting the "spread" parameter. That's discussed in the documentation too.

I strongly encourage using a slippage model that mimics ones experience in real world trading. While it may be exciting to see fabulous results in a backtest, those results are no better than the assumptions you give it up front. Unrealistic assumptions will lead to unrealistic output and expectations.

Good luck

Thank you so much for the detailed explanation, Dan!