What is the bid-ask spread?

By Oalgo · Last reviewed

The bid-ask spread is the gap between the highest price a buyer is currently offering (the bid) and the lowest price a seller is currently asking (the ask). Buying at once costs the ask and selling at once receives the bid, so the spread is a cost you pay on every round trip.

Diagram: a list of waiting prices. Three asks above, 100.30, 100.20 and 100.10, and three bids below, 99.90, 99.80 and 99.70, with the amount waiting at each price. The gap between the lowest ask, 100.10, and the highest bid, 99.90, is marked as the spread, 0.20.Amount waitingSpread 0.20AsksBids100.305100.208100.103Lowest ask 100.1099.904Highest bid 99.9099.80699.709
Example prices, made up for this page.

How do you read the bid and the ask?

#

The venue keeps a list of the orders waiting at each price, the order book. Sellers' waiting orders are the asks, buyers' waiting orders are the bids. The ask that matters is the lowest one and the bid that matters is the highest one.

SidePriceAmount waiting
Ask100.305
Ask100.208
Ask (the lowest)100.103
Bid (the highest)99.904
Bid99.806
Bid99.709
Made-up exampleValue
Spread100.10 − 99.90 = 0.20
Middle price(100.10 + 99.90) ÷ 2 = 100.00
Spread as a share of the middle price0.20 ÷ 100.00 = 0.20%
Buy one unit and sell it straight backPay 100.10, receive 99.90: 0.20 lost to the spread
Buy 6 units at once3 at 100.10 + 3 at 100.20 = 600.90, an average of 100.15

The last row is why a buy order larger than the amount waiting at the lowest ask fills at a worse average. That extra cost is slippage.

What makes the spread wider or narrower?

#
  • More buyers and sellers waiting close to each other make it narrower.
  • Few orders waiting, or a fast move in price, tend to make it wider.
  • It is quoted in price units, or as a share of the price, so a spread of 0.20 means different things at a price of 10 and at a price of 1,000.

How does a backtest count the spread?

#

A test on candles has an open, high, low, close and volume for each candle. It has no bid or ask, so it cannot see the spread. In Oalgo a test adds a fixed cost on every entry and every exit instead: the setting Slippage + funding %, which starts at 0.03%. It is how Oalgo counts how much worse your price is than the chart price, and the spread is one reason for that difference. A rule in Oalgo cannot use the spread as an input, because the order book is not part of the data a test runs on.

How can you allow for the spread in a rule?

#
  • Test the same rules with a higher Slippage + funding % than the default and compare the two backtest reports.
  • Remember that rules that trade often pay the spread more often. Ten round trips at 0.20% cost 2.0% of the price in spread alone.
  • An exit target smaller than the cost of the spread cannot leave a gain.

What can the bid-ask spread not tell you?

#

The spread is a snapshot. It changes from moment to moment and can be much wider than usual in a fast move, which no fixed percentage in a test can copy. It says what a trade costs to get in and out, not which way price will go. Neither a backtest nor a forward test places a real order, so neither shows the spread you would have met.

In Oalgo you can tell Oalgo AI your rule in your own words, check the rule it builds, and test it with a Slippage + funding % that allows for the cost of the spread. After testing, if you choose, you Go Live with your own Live Strategy on your own Venue Account at a Supported Venue.

Read next