DEV Community

Fancy Diamond
Fancy Diamond

Posted on Originally published at diamondexchapi.live

Back and lay odds explained for exchange sites

An exchange-style site shows two prices for every selection: a blue back price and a pink lay price. This guide explains what each one means, how much a bet wins or risks, and how to read the ladders from the Diamond Exch API.

Back: betting that it happens

A back bet wins if the selection wins. At decimal odds of 2.88, a stake of 100 returns 288: the 100 stake plus 188 profit. If the selection loses, the stake is lost.

Lay: betting that it does not

A lay bet takes the other side: it wins if the selection does not win. Laying 100 at 3.00 wins the backer's stake of 100 if the selection loses, and pays out 200 (100 × (3.00 − 1)) if it wins. That 200 is the lay bet's liability, and it is what your platform must hold while the bet is open.

A match odds board

Selection Back Lay
Sri Lanka 2.88 3.00
Pakistan 1.49 1.52

The back price is always a little below the lay price. The gap is the spread; on a busy market it is one tick.

Size: how much is available

Each price comes with a size: the amount that can be matched at that price. A ladder lists several prices, best first, so your site can show three back and three lay boxes like the big exchanges.

"runners": [{
  "name": "Pakistan", "status": "OPEN",
  "back": [{ "price": 1.49, "size": 1525.4 }, { "price": 1.48, "size": 980 }],
  "lay":  [{ "price": 1.52, "size": 640.1 }]
}]
Enter fullscreen mode Exit fullscreen mode

Profit and liability in code

// decimal odds; returns the player's profit (negative = loss)
function exchangePnl({ side, odds, stake }, selectionWon) {
  if (side === 'back') return selectionWon ? stake * (odds - 1) : -stake
  return selectionWon ? -stake * (odds - 1) : stake   // lay
}
const liability = ({ side, odds, stake }) => side === 'back' ? stake : stake * (odds - 1)

exchangePnl({ side: 'back', odds: 2.88, stake: 100 }, true)  //  188
exchangePnl({ side: 'lay',  odds: 3.00, stake: 100 }, true)  // -200
Enter fullscreen mode Exit fullscreen mode

Not every market is decimal

Match odds use "format": "decimal". Bookmaker markets on the same match quote a rate, the profit per 100 staked, where decimal = 1 + rate / 100. Always read format before using a price; the API reference lists all four formats.

When not to take a bet

Take bets only while the market's status is OPEN. Close your book on SUSPENDED (a goal, a wicket, a review), on BALL_RUNNING in cricket, and on any market marked "stale": true.

FAQ

Why is the lay price higher than the back price?

Because they are two sides of the same bet. You back at the best price someone will lay at, and lay at the best price someone will back at; the gap between them is the spread.

Does the API send more than the best price?

Yes. Each runner carries a back and a lay ladder, best price first, each level with its price and available size.

Is this Betfair's own feed?

Diamond Exch API is an independent provider, not run by or affiliated with Betfair or Diamond Exchange. The prices follow the exchange markets operators expect.


First published at diamondexchapi.live/guides/back-and-lay-odds-explained. Full API reference: docs.diamondexchapi.live. Runnable examples in Node, Python, PHP and curl: github.com/fancy-diamond/diamondexchapi-api-examples.

Top comments (1)

Collapse
 
noel_42a495eaa4b1b976448c profile image
Noel •

Nicely explained. Thanks a lot