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.
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.
| Side | Price | Amount waiting |
|---|---|---|
| Ask | 100.30 | 5 |
| Ask | 100.20 | 8 |
| Ask (the lowest) | 100.10 | 3 |
| Bid (the highest) | 99.90 | 4 |
| Bid | 99.80 | 6 |
| Bid | 99.70 | 9 |
| Made-up example | Value |
|---|---|
| Spread | 100.10 − 99.90 = 0.20 |
| Middle price | (100.10 + 99.90) ÷ 2 = 100.00 |
| Spread as a share of the middle price | 0.20 ÷ 100.00 = 0.20% |
| Buy one unit and sell it straight back | Pay 100.10, receive 99.90: 0.20 lost to the spread |
| Buy 6 units at once | 3 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
- What is slippage? Why a fill differs from the chart priceSlippage is the gap between the price a trade was expected to fill at and the price it got. Learn why it happens and how a backtest counts it as a cost.
- What is volatility? How it is measuredVolatility is how much and how fast price moves, not which way. Learn how ATR and standard deviation measure it, with a worked example.