
Reading and combining prices
3 minDifficulty Checked 2026-11-10- 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.
Reading one oracle. Use ledger_entry with the owner's account and the OracleDocumentID. The response is the Oracle entry with its PriceDataSeries and LastUpdateTime.
get_aggregate_price request:
| Field | Required | Meaning |
|---|---|---|
base_asset | Yes | Asset to price |
quote_asset | Yes | Asset the price is quoted in |
oracles | Yes | 1 to 200 objects, each with account and oracle_document_id |
trim | No | Percentage of outliers to trim, 1 to 25 |
trim_threshold | No | Time range in seconds for dropping older data. Default 0, no filter |
Response:
entire_set:mean,sizeandstandard_deviationfor all collected prices.trimmed_set: the same three values after trimming. Present only whentrimwas sent.median: the median price.time: the most recentLastUpdateTimeamong the oracles, in Unix time.
How the data set is built:
- The newest
LastUpdateTimeamong the listed oracles is the upper time limit.trim_thresholdcounts back from it. - An oracle is included if it has the pair, has an
AssetPriceand falls inside the time range. - If an oracle's current entry has no
AssetPricefor the pair, the server examines up to three previous versions and uses the most recent one that qualifies. - Duplicate oracle identifiers are ignored.
Errors:
objectNotFound: no prices in the data set.internal:trim_thresholdremoved every price.oracleMalformed: theoraclesarray is malformed or outside 1 to 200.
The method is read-only. It runs on a server and returns statistics. It does not write an aggregate price to the ledger.
Related: Prices on the ledger, Running a node: xrpld and Clio.
- get_aggregate_priceRead 2026-11-10
- Oracle ledger entryRead 2026-11-10
- ledger_entryRead 2026-11-10
- Price OraclesRead 2026-11-10
