Back to Community
Orders not filling for even small amounts

The good:

I love the idea of Quantopian, and I've become addicted. I'm a day trader, and I'm also a Sr. Solution Architect and software engineer. When I trade, I trade based on momentum. I look for new highs on stocks intra-day, and I trade in the $1 - $10 range, all the time in Scottrade. The idea that I could write code to do what I do, and go somewhere else and sip on a mojito is something I simply adore, and if I can program the system to do what I do normally, that will be awesome.

The bad:

The fact that I can't fill 100 shares on a stock that averages a 1,000,000 shares traded over the last 30 days is beyond absurd. And anyone who argues this has either never traded in their life, or simply doesn't know any better. I usually go in on orders with my hot keys in Scottrade Elite for 10,000, sometimes 30,000 shares. More often than not, I get filled almost immediately, even with limit orders. And I usually sell, after a penny or two on the move. I've read all the horse manure about how accurate your slippage model is, and I can tell you it's total BS. For starters, my algorithm is struggling to fill 100 shares, and none of the stop losses are executing period. I coded it to do a trailing stop loss, and I can watch as the price rises, and then for whatever reason Quacktopian arbitrarily decides that it would be impossible in that instant to sell 100 shares. I don't believe that Scottrade is the greatest broker in the world, not even for a minute. However, no one here is going to convince me that I shouldn't be able to get these shares bought and sold based at what I'm requesting. In addition, there is a MAJOR bug on market order the fills. It's as if you're actually trying to discourage programmers, rather than encourage them. I've gotten fills that were 50% above the high of day, which is just flat out stupid and doesn't happen, even in after hours trading. Quantopian is probably the greatest idea since sliced bread, but until the developers take a good look in the mirror and try to simulate real word trading, rather than saying they do, we'll all be stuck to momentum trading the DOW. Now, I could be dead wrong and it could be my code, but since there seems to be a random number generator behind the fill routines for market orders, I don't think that's feasible. Can we at least get the StopLimit working? Somebody. Anybody. Please help.

Clone Algorithm
Backtest from to with initial capital
Total Returns
Max Drawdown
Benchmark Returns
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: 591124ed8d263061e4a27bd7
There was a runtime error.
6 responses

There is a good explanation of the slippage model used by the backtester in Quantopian documentation

You might find interesting that it is possible to customize the slippage model, so that it better suit your evidence of how the market behaves.

Also, this is a blog post by Quantopian that you might like to read

The notes below denote that you are restricted to a certain amount of the Market's volume:

When an order isn't filled because of insufficient volume, it remains open to be filled in the next minute. This continues until the order is filled, cancelled, or the end of the day is reached when all orders are cancelled. Slippage must be defined in the initialize method. It has no effect if defined elsewhere in your algorithm. If you do not specify a slippage method, slippage defaults to VolumeShareSlippage(volume_limit=0.025, price_impact=0.1) (you can take up to 2.5% of a minute's trade volume).

  1. Let's say we are at bar 1
  2. There are 300,000 traders who want to buy stock from company ABC
  3. The first trade places a buy order for 10,000 shares, and prior to his trade, there is no volume.
  4. If this platform is basing my ability to buy based on a percentage of the volume, assume all 300,000 traders were Quantopian algorithms, would anyone be able to get filled?

It may sound like a stupid question, but if I can only buy based upon 2.5% of the minutes trading volume. Then the slippage model is saying that I can't buy unless someone else buys. Isn't that a Chicken and Egg scenario? Shouldn't my buys be based on Company ABC's outstanding shares with respect to their demand? Maybe, I'm not understanding. So, someone who is an an expert level, please explain this paradox.

Slippage is used to simulate"What would have happened in the past if we had bought/sold those securities in that amount?". This obviously doesn't apply when you deploy your algorithm for live trading, in this case the orders are sent to your broker (IB or RH) and the market will decide when/how your orders will be filled. Quantopian slippage model (and commission model) is irrelevant in live trading.

So slippage is only used to have a reasonable simulation of the past so that you can evaluate your strategy. When you develop your Slippage model the main concern is to not be too optimistic so that you don't live trade strategies that work well only in backtesting. The second goal of a Slippage model is to be realistic, so that you can see if a trading strategy works. This might be difficult in the sense that the model might work well for the majority of the stocks (e.g. high volume stocks) but it might have some problem with a particular class of stocks (e.g. low volume stocks). This is the reason why Quantopian allows to define your custom slippage model, to better suit the class of stocks that your strategy trades.

The accuracy of Q slippage model seems to be your concern: you have evidence that your have better chances in reality to fill your orders than what happens in the backtester. I would suggest to customize your slippage model so that it is in line with what you see in reality and so you can trust the results of your backtests. If you have an Interactive Brokers account you can paper trade your algorithm with them before going live, in this way you also test another independent slippage model, reducing the risk of having been too optimistic before going live.

Regarding your last questions:

Volume is the number of shares or contracts traded in a security or an entire market during a given period of time. For every buyer, there is a seller, and each transaction contributes to the count of total volume.

Volume information makes sense only for historical data, that is when the slippage model is used. For live trading it is the market that decide when your orders are filled and how much. So I am not sure to understand the question you raised.

Thank you very, very much. It makes perfect sense the way you explained it.

"This obviously doesn't apply when you deploy your algorithm for live trading, in this case the orders are sent to your broker (IB or RH) and the market will decide when/how your orders will be filled. Quantopian slippage model (and commission model) is irrelevant in live trading."

I simply could not imagine not being able to purchase shares. I trade with Scottrade Elite and I trade large quantities of penny stocks all the time with no issues getting in or out with limit orders. I get filled in seconds and I'm out in seconds, after a penny or two on a move either way. I typically look for volume over a million and floats above 100 million.

Now, given you were smart enough to answer my question, and what you are stating actually makes sense, can I turn slippage off and get my orders filled immediately. Granted this is gleefully optimistic, but it's more in line with my experience during peak trading hours. Again, thank you for the awesome info.

You can set the following in the initialize function of your algorithm:


From the documentation:

Fixed Slippage

When using the FixedSlippage model, the size of your order does not
affect the price of your trade execution. You specify a 'spread' that
you think is a typical bid/ask spread to use. When you place a buy
order, half of the spread is added to the price; when you place a sell
order, half of the spread is subtracted from the price.

Fills under fixed slippage models are not limited to the amount traded
in the minute bar. In the first non-zero-volume bar, the order will be
completely fille
d. This requires you to be careful about ordering;
naive use of fixed slippage models will lead to unrealistic fills,
particularly with large orders and/or illiquid securities.

Thanks. Based on what you stated, the typical spread for the stocks I trade is 1 to 2 cents. So, I'm assuming this would be in line with those metrics.


I'll give this a try and see if I get filled immediately and stop seeing end of day errors on every trade.