Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to avoid order to be filled in multiple blocks of shares?
API

What if I want to buy 100 shares in a single trade ? not get filled with blocks of 25 shares with a couple minutes of interval... !!

5 responses
set_slippage(slippage.FixedSlippage(spread=0.00))  

Have a look at the Slippage section in the API documentation for an explanation.

Bear in mind that in real life, you can be filled piecemeal over the course of a few minutes, so if your algo is not capable of handling this, it will break down sooner or later.

Simon, So you are saying that there is no way to control in real life if your order get filled in a single complete block of shares or if it gets filled in 3-4 small blocks ?

You can use all or nothing / fill or kill orders to be sure you will be executed as a single block. The risk here is not to be executed at all and end up filled at a worse price later. These orders are not supported by Quantopian anyway.

Yes, Fill-Or-Kill is both All-Or-Nothing and Immediate-Or-Cancel, but none of this is supported by Quantopian. The best workaround I have found is cancelling outstanding orders before doing something new on the same symbol, and being diversified enough that being a little off here and there isn't going to ruin you. In practice, it seems like fills in illiquid securities are generally much quicker than simulated, but sometimes worse in terms of price, doubly so for ETFs.

But definitely, it's worthwhile to keep these sorts of situations in mind if you are going to trade real money.

Pathologically, things get even worse, if you are trying to micro-manage orders with Quantopian; orders can be held, or rejected. Cancels can be rejected, or only partially cancel if a fill crosses paths with a cancel. Orders can be partially and never completely filled, mostly limit or stop-limit orders. Stop orders can be skipped over, or filled at unexpected(ly bad) prices.

Lots to worry about, if you care to!