EN

Reading and combining prices

3 minDifficulty Checked 2026-11-10
Key takeaways
  • get_aggregate_price combines up to 200 oracles for one pair.
  • Trimming drops the highest and lowest values before averaging.
  • A time threshold filters out prices that are too old.

Reading one oracle means trusting one publisher. A safer habit is to ask several and compare.

Suppose five oracles post a price for the same pair. Four say about 100. One says 900. A plain average gets dragged up to 260 by the odd one. Two better answers:

  • The median is the middle value when you line them up. Here it is about 100.
  • A trimmed mean throws away the highest and lowest values first, then averages the rest. Also about 100.

The XRP Ledger's servers can do this math for you. One request names a pair and a list of oracles. The answer comes back with the mean, the median and, if you ask, a trimmed mean.

Age matters as much as agreement. A price from an hour ago can be far from the market now. The same request can set a time window. Oracles whose last update falls outside the window are left out.

Before relying on any oracle, look at it:

  • Who owns it? Check the owner address, not only the provider name. The name is free text.
  • When was it updated? Compare the timestamp with the current time.
  • Does the pair have a price? A pair with no number was skipped in the last update.

No setting makes a bad source good. Aggregation limits the damage from one wrong oracle. It does not help if most of the list is wrong.

Check yourself3 questions
1. What does the trim setting do in get_aggregate_price?
2. You list the same oracle twice in one request. How is it counted?
3. Which check tells you who is behind a price?
Sources
Next moduleDIDsI1 · 10 min