Back

Slippage and Latency

Hey.

How is the latency impact on slippage replicated in backtesting?

And when live trading, what's the current relation between the slippage experienced and the latency between the platform's servers and each broker?

I've always wondered the impact of those on higher resolution strategies, could anyone help me to understand it better?

Thanks.

Update Backtest








Hi Andrestone,

Recently I had a set of threads discussing about similar issues. What you should know:

1- QC uses an ImmediateFill when you place a market order. This means that if you are testing with high resolution data, your tests may not ber very realistic. So you may want to add an artificial delay to your orders.

2- When you place a Limit (or Stop Limit) order, it might get partially filled or not filled at all until a lot later (or never). So you need to track your tickets and probably cancel them if needed.

3- If you place an order with 1 million share, the framework will fill it for you. In real life that is not how it might work. So, it's good to be aware of the volume and quote data in real life.

 

If you are dealing with lower resolutions, these may not cause any problem at all.

 

1

Hey Patrick, 

Thanks a lot for your comment.

Is there any update QCU code or maybe even some of your published algorithms where you make use of these practices? Maybe someone else's?

 

0

Unfortunately I'm not aware of others and it's very hard to find stuff in QC's forum by searching in google. For some reasons google doesn't index these contents correctly.

What I did was, when I needed to place a Buy Order, instead of doing it immediately, I turned a flag on and continued. Then when the OnData comes, I check to see if the flag is on, if it is then I actually place the Order now and turn the flag off for the next use. For selling I used a similar logic.

Here is a pseudo code:


private bool orderBuy = false;

public void OnData(...) {
if (orderBuy) {
Order("SPY", 100, ...);
orderBuy = false;
}
if (BuySignal) {
// here we don't place the order. postpone it to the next OnData loop
orderBuy = true;
}
}

 

Here it's using a boolean and can only delay the order for one period but you can make it as an integer that acts as a counter until that many seconds is pass and then place the order.

 

0

Update Backtest





0

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.


Loading...

This discussion is closed