Skip to content
All library documents

Bid and Ask Data, Order Fills, and Slippage in Backtests

Article Quant Q&A · Author: Dark Knight

Summary

The discussion compares accounts of quote data and order handling in the QuantConnect backtesting environment, while also mentioning Quantopian and other tools in the question. One answer says the platform lacked bid and ask data at the time described and characterizes market orders as filling at the current price, with configurable slippage. It also notes that limit-order fills can be delayed, especially for low-volume stocks with wide spreads, and that simple simulations may not capture how displayed orders affect other traders.

A second answer gives a different, updated account: QuantConnect’s US equity backtesting uses level-one quote data, alongside trade data, and describes quote availability across asset classes and bar frequencies. These answers reflect changing platform capabilities and should be read in their historical context rather than as current documentation. The exchange highlights why fill assumptions, spreads, quote availability, and market impact matter when interpreting backtest results, but it does not present a validated universal model for realistic execution.

Key ideas

  • Backtest conclusions depend on whether the data include bid and ask quotes as well as trades.
  • Market orders filled at a current price may omit spread costs unless modeled.
  • Limit-order fills can be delayed, particularly in low-volume stocks with wide spreads.
  • Historical platform data capabilities can change, so the answers may not describe current offerings.
  • Simple order-fill models may miss market impact and the response of other traders.

Tags

Full text
# Does QuantConnect use both bid and ask data for backtesting?


# Does QuantConnect use both bid and ask data for backtesting?












Or Quantopian?

How about Python libraries like ultrafinance and PyAlgoTrader?

## Answer by user24922 (score 2, accepted)

https://quant.stackexchange.com/a/30657

At the moment QuantConnect doesn't have bid & ask data.

However, I've been using limit orders in my backtests, and adjusting the limit orders. I'm guessing what they do is fill your limit order according to the trades coming in... so limit order backtests 'steal' the trades as they come in, until your limit order is filled.

For low volume stocks with big spreads, your limit order may not get filled for a long time...

Their 'standard' Order() method just fills your order at the current price. You can also model slippage ( 1/10th of 1% in this example):

```
Securities[symbol].SlippageModel = new ConstantSlippageModel(0.001m);
```

All that said, there really is no good way to model bid/ask in a backtest, because in the real world, placing a large-ish limit order often scares off real world traders.

## Answer by JaredBroad (score 6)

https://quant.stackexchange.com/a/30476

QuantConnect uses L1 data (bid and ask quotes) for its US Equities Backtesting.

QuantConnect has a full break down of the data library, including free data for download in LEAN format at the data library page: https://www.quantconnect.com/data

The open-source LEAN algorithmic trading engine can support trades and quotes, however, on QuantConnect website the free data library is:

US Equities - Trades and Quotes data in tick, second, minute, hour and daily bars. Quote data was added to backtesting in April 2020.

US Fundamentals - MorningStar corporation fundamentals.

FOREX & CFD - Quotes; Tick, second, minute, hour and daily bars for FXCM and Oanda market providers. Bars are from the midpoint of the quote data.

US Options - Trade and Quote Minute Bars.

US Futures - Trades, Quotes; Tick, second, minute, hour and daily bars.

(Disclosure, I am the Founder of QuantConnect)

Edit: Updated state of Futures and Options, and US Equity Quote.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.