Back to Community
Do I need slippage on limit orders?

To try and replicate real world slippage - Do I need to add slippage on limit orders?

I get market orders, but limit orders should fill for what your limit is... right?

6 responses

I also have questions here - is it even possible to put slippage in live trading orders?

@Tyler

Yes, you should probably add (or just keep the default) 'slippage' model for limit orders. Slippage not only refers to the calculation of a realistic price but also a realistic volume. Check out the documentation https://www.quantopian.com/help#ide-slippage.

The slippage method also evaluates if your order is simply too big:
you can't trade more than market's volume, and generally you can't
expect to trade more than a fraction of the volume. All of these
concepts are wrapped into the slippage method.

It's true that a limit order won't fill for anything worse than the limit price. However, they may fill BETTER than the limit price. That price is based upon the slippage model.

@ QQQ
'Slippage' is purely a backtesting construct. In live trading, any slippage functions are disregarded. In live trading, the algorithm doesn't calculate the expected price and volume (ie the slippage). In live trading, the actual broker trade data is used. You can 'put' code in for slippage in a live traded algorithm (or more likely simply leave it in from your backtests) but it will have no effect.

@Dan - I've found where my $5,000 XIV order was spread out on default slippage. There is no way this would happen in live trading as this ETF is super liquid, especially with only a 5,000 order.

The default slippage model has a lot of basis in real world results (see https://blog.quantopian.com/accurate-slippage-model-comparing-real-simulated-transaction-costs/ ) though it does have limitations. It's probably over aggressive in spreading out trades across multiple bars especially with liquid stocks. However, what that spreading out can do is determine a more realistic 'average actual price paid' even though in live trading that may have all traded in a single bar. Another result of spreading out (especially with limit orders) is to guesitmate when the order actually fills. If it takes 20 bars to fill an order in backtesting using the default slippage model, then in live trading one can be reasonably sure the order will have filled in 20 minutes (even though it may have filled in a single bar).

The 'spreading out' won't affect most algorithms unless one is buying and selling minutely quite a lot. If that's the case then one can always set a higher volume limit on the slippage model. Though, changing it would probably just rely on ones 'hunch' as to the best value. The only true test is by live trading the algorithm.

"There is no way this would happen in live trading as this ETF is super liquid, especially with only a 5,000 order"

XIV wasn't always 'super liquid'. If you are looking at backtests from 2011-2013 the volumes weren't nearly as high and an order could easily be spread out across multiple bars with the default model (see attached notebook). This is one of the dilemmas of backtesting. We are using past data to infer future performance. However, we all know that 'past performance does not predict future performance'. A big assumption in backtesting is that the future data will be like the past data. With new ETFs especially, the first year or so after inception, the volumes are typically very low (until the market begins to accept them). That past data will NOT represent future data very well.

Loading notebook preview...
Notebook previews are currently unavailable.

Hi Dan,

Regarding your comment about XIV liquidity, looking at the ETN's volume alone does not tell you the whole picture. The liquidity of ETF/ETNs are dependent on their underlyings' liquidity, in this case VIX futures. It is possible for thinly traded ETF/ETNs to have very high liquidity if their underlyings have sizable volume. VIX futures daily average volume is about $5 billion (for context, SPY's daily average volume is about $28-30 billion). As such, I do not believe the default slippage model is appropriate for all ETF/ETNs. It is most accurate only for individual stocks IMO.

You can read more here: https://am.jpmorgan.com/blob-gim/1383272223898/83456/1323416812894_Debunking-myths-about-ETF-liquidity.pdf

@Dan Whitnable

minutes_to_trade = 5000 / (day_pricing.mean_minute_dollar_vol * .025)  

I see you are taking the mean minute dollar volume.. and seeing how much volume there was to sustain an order of 5000 shares. the * 0.25... what does 0.25 represent?