Hi guys!
There have been some pretty interesting posts on the effect of slippage on model performance. However, reading these posts gave me insight on a meta level, nevertheless I'm not yet able to translate these results into the implecations for my own strategy. So i need your help :)
I have a question regarding slippage modeling in pair trading. I have implemented a pretty simple pair trading algoritme looking at zscores of cointegrated equity pair. Trading these pairs successfully in both backtests an out of sample data (live paper trading). The juice of this strategy is in how to find the pairs and when to stop using a pair. However, so far my models did not take into account slippage. Currently I'm trading at a minute Resolution and most holding periods are pretty short mostly only a few minutes let's say in the 2 to 20 minute range.
Implementing a custom slippage model from the documentation about reality modeling is obviously detrimental to the performance of my model:
class CustomSlippageModel:
def __init__(self, algorithm):
self.algorithm = algorithm
def GetSlippageApproximation(self, asset, order):
# custom slippage math
slippage = asset.Price * 0.0001 * np.log10(2*float(order.AbsoluteQuantity))
self.algorithm.Log("CustomSlippageModel: " + str(slippage))
return slippage
Yet, I'm wondering whether this is a relevant manner to model slippage for the type of model since this assumes slippage is always negative. With a marketorder being both long and short in similar equities this might not be as relevant.
To test the robustness of my strategy I'm thinking of different manner of introducing 'slippage'. My idea is to trade (instant) on the t-1 signal (i.e. trading now on the signal of one minute ago). This will introduce a kind of 'slippage' that might be both positive and negative.
So questions that might be interesting for a broader audience:
- How relevant is slippage modeling in pairs trading?
- How to test if a pair trading strategy is robust agains slippage?
- Would it yield valuable insight knowing how a strategy performs on a t-1 signal?
Petter Hansson
For low volume (compared to instrument liquidity) trading where market impact isn't the concern I would do this:
For market orders the slippage comes from crossing the spread, and for pair trading you still need to do this for shorts when selling to buyers on the ask - pair trading inevitably still carries this cost. Then there's the slippage which comes from latency, i.e. from the price moving before your order reaches the exchange. This kind of slippage can actually work in your favor (and the underlying market move may potentially cancel out when trading a pair as you describe) but it is heavily dependent on your strategy.
The most easy short term alpha (e.g. due to a few seconds of difference in price) you can find in backtests will actually be arbitraged away by the time your order goes through on IB. Solution: Don't try to compete with HFT and trade longer time frames. If you have too small profit/losses in the backtest results, chances are your algo will be unprofitable when traded on IB.
Dirk bothof
Thanks for the great answer Petter! This has gotten me a lot further, I think this can help other people a lot as well. Currently, I'm connected to IB for paper trading to measure what is happening. My hopes are not very high since in several backtest scenario's I find that slippage is killing! Nevertheless, I want to learn from the experience to see the effects of 'real' (sort of real) slippage.
Small question to somebody following:
- currently i have a interactivee broker paper account, I have set up the live trade clicking on interactive brokers but using the quantconnect datastream, do I still get a fair estimate of the incured slippage that can be expected in live trading? or does this also needs the IB datastream aka go through full account procedure and get data subscription?
Best,
Dirk
Alexandre Catarino
Hi dirk bothof
Live data from QuantConnect comes directly from the exchanges.
If you don't have a data subscription with IB, I don't think you need one, since the difference in the price in the data sources, which is small, is probably not one of the biggest components of slippage.
Dirk bothof
Agreed, however the QC data has no bid ask information as far as I know, this is pretty relevant if for slippage.
So as general datasource QC is fine to build the trading signal. To learn more about how the algoritme will behave 'in the wild' (live trading real money) I would like to use the order execution engine of Interactive Broker (which i assume has bid and ask information)
]
Jared Broad
FYI We'll have spread soon -- we've procured the data and are working on installing it now.
The discussion above seems like a misunderstanding as spread != slippage, pure slippage is normally the difference in price between when you place the order and when its filled, and that should be minimal as our execution times are minimal and host racks stable. Even with spread data, there can still be additional slippage from the market moving from when you place the trade.
Spread will have an impact if your margins are narrow, we hope the new spread data will help better model tight margin strategies. Generally, for now you could put in a slippage model which approximates spread -- the model you use would depend on the assets you are trading.
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.
Petter Hansson
Spread for practical purposes becomes a component of slippage when I can't model it. But yeah, should maybe be more careful about term usage here.
IB has internal latencies and can fill after several seconds at their own disgression. My understanding is they can even deliberately buffer orders for a while in order to increase chance of having them internalized.
Great to hear about spread data Jared!
Dirk bothof
thanks for the answers guys! Cool to see the level of knowlegede, I have a lot to learn :)
Bid ask data would be pretty cool to do some nice caluculations on! (it's out of scope of this thread but curious as to if this will be included in backtests automatically)
I will try and setup my IB tonight and see the results the comming weeks.
Alexandre Catarino
Hi dirk bothof ,
Yes, it will be available in both backtest and live mode at the same time.
Dirk bothof
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!