I have been in turmoil in trying to combat slippage lately. I have been tinkering with some mean reversion equity strategies that make high frequency trades. The more short term and lower price the security, the better they seem to perform. The real problem I've found is that it seems like the difference between the ask and bid at any given buy and sell for a transaction is greater than the difference between the close of the given buy and sell; meaning the profit margins are negative even though it was a winning sell; It's so hard to tell. So you can see I've developed a healthy fear for slippage.
I've been incorporating a slippage estimation function for each buy and sell based off the following formula I adapted from a forum post I lost reference to. I know a more accurate formula could be derived with the ask & bid prices, but alas, I don't have reasonable effort access to them.
if (this.ClosePrice < this.OpenPrice)
{
potentialSlippage = this.LowPrice - this.OpenPrice;
}
else
{
potentialSlippage = this.HighPrice - this.OpenPrice;
}
When incorporating this into my algorithm the results are rather depressing and is always a net loss. It's been a futile uphill battle of optimization to break even.
But one thing though I've come across time and time again when researching the matter is negative slippage vs positive slippage. So my question is, do you suppose I could assume maybe that if negative and positive slippage occurs about 50/50, that really it sort of evens out in the end and that I don't even need to worry about it? If that is remotely possible I understand it would be subject to volume and various other factors, but I'm talking generally even out. My function always assumes extreme negative slippage and it just doesn't work.
Also, have any of you who have even ran live with a high frequency algorithm ever have issues with slippage or does it even out for you?
I did find the following snippet from a forex post, but it sounds promising. Not sure if this applies to equity trading though:
Since it is market order, mean slippage per trade will be very little, as over time positive slippage will balance out with negative slippage. For me, i get a mean slippage per market order of negative 0.031 pips (over the last 400 market orders). My execution speed is about 800ms, i trade London + NY, and rarely make market orders at news times. I wouldn't worry too much about slippage for your back testing
http://www.forexfactory.com/showthread.php?t=337224
Oran Christian
Jared Broad
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Levitikon
Oran Christian
Levitikon
Oran Christian
Jared Broad
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Oran Christian
WinstonS
Hello, I have a question, when the function GetSlippageApproximation returns a value > 0 it's positive slippage ?. and negative when < 0 ?. Or it depends on the order (BUY vs SELL ).
Levitikon
I believe spillage is always positive; It's (price * slippage spread.) Now whether or not it gets added to or subtracted from the sale is determined by the order type as you can see in QuantConnect's ImmediateFillModel.cs:
//Calculate the model slippage: e.g. 0.01c var slip = asset.SlippageModel.GetSlippageApproximation(asset, order);
//Apply slippage switch (order.Direction) { case OrderDirection.Buy: fill.FillPrice += slip; break; case OrderDirection.Sell: fill.FillPrice -= slip; break; }
Levitikon
//Calculate the model slippage: e.g. 0.01c var slip = asset.SlippageModel.GetSlippageApproximation(asset, order); //Apply slippage switch (order.Direction) { case OrderDirection.Buy: fill.FillPrice += slip; break; case OrderDirection.Sell: fill.FillPrice -= slip; break; }
WinstonS
Thanks Levitikon. If I undertand the code correctly, I actually can create positive/negative spillage. For example if the order is BUY and I return a negative number from GetSlippageApproximation, I would get a positive spillage. I was thinking in create a model base on this numbers:
From this page.
Marc Nunes
Slippage will definitely matter and I'd say one key element that you'd want to account for and mitigate is market impact. On bid ask spread, unfortunately I don't see how to get realistic high frequency results unless you're backtesting on at least top of the book BBO quotes (as opposed to just trades/Bars). on mitigating market impact (but this you can't really see within QuantConnect), you may want to limit your "trading intensity" so that you're trading a certain fraction of a rolling window of trading volume.
JP B
@Levitikon How often do you trade? Is your algo really that high frequency?Do you also take into account that slippage scales with order size? Instead of assigning a fixed dollar amount to slippage, I personally prefer a function of size.
Also, high frequency algos often seem more profitable because of compounding. Have you tried non-compounding?
Bryan Fletcher | FXCM
Jiaqi chen
On a related note I am wondering how the market order price is determined in the lean engine. Using SPY as an example, we have a bid/ask of 210.45/210.46. If I am using a market buy order in the backtest does lean use 210.46 or 210.45? I am experimenting the impact of slippage so I am wondering whether I need to add 1cent of slippage in the backtest if I am using market order in the backtest engine? Thanks.
Jared Broad
you can try using it for your fills.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jiaqi chen
Levitikon
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!