HOME FORUMS BROKERS SOFTWARE BOOKS CONTACT US
Elite Trader Your Account  •  Become a Member  •  Help  •  Search    
    Forums ›› Technically Speaking ›› Automated Trading ›› How do you emulate slippage in a backtest?  


Post A Reply
    Page 1 of 3:   1  2  3  
jcl
 

Registered: Jan 2012
Posts: 407

 

08-21-12 11:42 AM

Slippage is normally irrelevant, but can remarkably affect the result when you trade on short time frames, such as minutes or ticks. So far I used the following formula for calculating slippage when entering a trade at the open:

P = S/T * (C-O)

where P = price change due to slippage, S = slippage in seconds, T = bar width in seconds, C = close and O = open.

This is the theoretical average slippage under the assumption of a honest broker, but I found that this generates usually too small slippage. Therefore I'm now using the following formula:

P = S/T * (L-O) when C < O
P = S/T * (H-O) otherwise

This seems to give more realistic results. Which slippage formula do you use?

    Edit/Delete Quote Complain
amazingIndustry
 

Registered: Aug 2009
Posts: 570

 

08-21-12 02:44 PM

you make the erroneous assumption that slippage is a function of future price moves during the time taken to get your order to market.

However, how you get filled, in practice, is much more a function of market intrinsics unless of course it takes an unreasonable amount of time for your order to get filled during which the market may have moved against you.

What I would do is to build a Transaction Cost Model, which you feed with historical slippage. This, imho will by far get you the most accurate figures. If you dont have the luxury to build such model then make very liberal assumptions about how you get filled especially if you trade with shady brokers or trade over a very slow connection.



Quote from jcl:

Slippage is normally irrelevant, but can remarkably affect the result when you trade on short time frames, such as minutes or ticks. So far I used the following formula for calculating slippage when entering a trade at the open:

P = S/T * (C-O)

where P = price change due to slippage, S = slippage in seconds, T = bar width in seconds, C = close and O = open.

This is the theoretical average slippage under the assumption of a honest broker, but I found that this generates usually too small slippage. Therefore I'm now using the following formula:

P = S/T * (L-O) when C < O
P = S/T * (H-O) otherwise

This seems to give more realistic results. Which slippage formula do you use?

    Edit/Delete Quote Complain
WinstonTJ
 

Registered: Jan 2009
Posts: 1947

 

08-21-12 04:14 PM

The best and most reliable way to apply what is essentially an educated guess is to run a live strategy and then run the live strategy through your simulator and compare the real trading results against your simulated results. Come up with an overall correction factor so that your backtest results are very realistic.

Guessing about slippage is almost impossible because you have to make too many assumptions. You need good data so that you can see what executed and at what price. Even then you can't assume that an execution would have been yours - it's always best to go a penny up/down from your target price. If you are trying to sell 1000 shares offered at $10.61 assume you get a fill when you see more than 1000 shares print at $10.62. That extra penny may be too pessimistic for some strategies but the reality is that if you have decent backtest results even with adding an extra penny on the entry and exit then you probably won't get a surprise when you put real money behind it.

If you are estimating slippage because you are using market orders - don't ever use market orders. Always submit marketable limit orders (meaning pay through the bid/offer). A marketable limit order always avoids slippage and guarantees fast execution as well as price improvement up to the NBBO.

    Edit/Delete Quote Complain
jcl
 

Registered: Jan 2012
Posts: 407

 

08-22-12 09:10 AM

Thanks, that makes sense. It is probably futile to apply a slippage formula. I run systems anyway in parallel on a life and on a demo account, so I record the slippage under that assumption that a demo account has no slippage.

So far slippage seems to depend on the quote rate and some random factor. The best solution is probably just some empiric value dependent on the asset and the trading time.

    Edit/Delete Quote Complain
braincell
 

Registered: Jul 2011
Posts: 538

 

08-22-12 11:49 AM

To get accurate slippage you need to simulate the order book. That is almost impossible because of so many unknowns, as well as how/when/why the MMs will give you a price vs when they won't participate. In many of my strategies I have to use stop orders (for entries) which convert to Market (obviously) and in my experience it's best to have some tick data (not much, but some) from which you can estimate the slippage others were getting. It's a good enough approximation if you look at the Last ticks and then compare to Bid/Ask ticks, you can soon narrow down the standard deviation of slippage, and the best part comes when you link the StdDev to volatility. That way you get a model that's "accurate enough", ie transaction costs model of sorts like amazingIndustry mentioned. It won't be perfect but it's something. You should, in any case, leave room on your backtester to make slippage pessimistic. If you can't afford to do this, assume some distribution of slippage vs volatility (it is close to normal in my experience) and use random numbers to generate slippage.

This of course only for Market (and Stop) orders, for limit, you just get filled when the price penetrates your level by a tick, but if you are using odd lots for orders (stocks) then you might not get filled on low liquidity stocks if the other side is looking for all-or-none (or avoids odd lots). So... liquidity is an issue with simulating limit orders so you may want some assumptions there as well, if you want to be very close to perfect.

    Edit/Delete Quote Complain
libertine
 

Registered: Sep 2004
Posts: 44

 

08-22-12 12:41 PM

I daytrade stocks and enter at market. For simulations I use data from (a lot of) previous live trades. Slippage is a big deal for me, so I need to simulate it properly or I'll be wasting my time.

The two factors that influence it the most are time of day - slippage is higher closer to the open - and liquidity of the stock in question. The best way I have found of measuring liquidity for this purpose is to multiply the average share volume of the past 20 days by last close. Higher liquidity gives lower slippage, no surprises there.

So in practice I end up with an overall average slippage, and for each individual simulated position opened that average is adjusted according to time of trade and liquidity of stock traded. If the position is stopped out I need to add in slippage again, with the time of closure being the only change. For profitable trades I use limits and simulate a close if price penetrates my level. As braincell noted that may be a little optimistic, but I'll allow myself that indulgence.

If anyone is interested I can post up some examples.

    Edit/Delete Quote Complain
    Page 1 of 3:   1  2  3  
Post A Reply


Receive an email whenever a new post is added to this thread by subscribing to it.
 
Rate This Thread:

Forum Jump:
 

 

   Conduct Rules  -  Privacy Policy  -  Day Trader -  Day Trader Forum -  Best Trading Software -  Sitemap Copyright © 2013, Elite Trader. All rights reserved.    
 
WHILE YOU'RE HERE, TAKE A MINUTE TO VISIT SOME OF OUR SPONSORS:
Advantage Futures
Futures Brokerage & Clearing
AMP Global Clearing
Futures and FX Trading
Bright Trading
Professional Equities Trading
CTS
Futures Trading Software
DaytradingBias.com
Professional Trading Analytics
ECHOtrade
Professional Trading Firm
eSignal
Trading Software Provider
FXCM
Forex Trading Services
Global Futures
Futures, Options & FX Trading
Interactive Brokers
Pro Gateway to World Markets
JC Trading Group
Direct Access Trading
MB Trading
Direct Access Trading
MultiCharts
Trading Software Provider
NinjaTrader
Trading Software Provider
OANDA
Currency Trading
optionshouse
Option Trading & Education
Rithmic
Futures Trade Execution Platform
SpeedTrader
Direct Access Trading
SpreadProfessor
Spread Trading Instruction
thinkorswim by TD Ameritrade
Direct Access TradingAdvertisement
TradersStudio
System Building & Backtesting
Trading Technologies
Trading Software Provider
Trend Following
Trading Systems Provider