For the complete documentation index, see llms.txt. This page is also available as Markdown.

get_aggregate_price

Retrieves the aggregate price of specified Oracle objects, returning three price statistics: mean, median, and trimmed mean.

This method will use 20 Compute Units.


Reference: Here

Parameters

  • base_asset (string, required) The currency code of the asset to be priced.

  • quote_asset (string, required) The currency code of the asset to quote the price of the base asset.

  • trim (number, optional) The percentage of outliers to trim. Valid range is 1 to 25. If included, the API returns statistics for the trimmed mean.

  • trim_threshold (number, optional) A time range in seconds for filtering out older price data. Default is 0, which does not filter any data.

  • oracles (array, required) Between 1 and 200 oracle identifier objects, each with account (the account that controls the Oracle object) and oracle_document_id (a number).

  • ledger_hash (string, optional) The unique hash of the ledger version to use.

  • ledger_index (number or string, optional) The ledger index of the ledger to use, or a shortcut string such as validated, closed or current.

Returns

  • entire_set (object) Statistics from the collected oracle prices: mean, size and standard_deviation.

  • trimmed_set (object) Statistics from the collected oracle prices after trimming outliers: mean, size and standard_deviation. Only present if trim was given.

  • median (string) The median price.

  • time (number) The most recent timestamp out of the LastUpdateTime values, in Unix time.

  • ledger_hash, ledger_index or ledger_current_index, validated The ledger version used.

Over WebSocket, send {"id":1,"command":"get_aggregate_price","base_asset":"XRP","quote_asset":"USD","trim":20,"oracles":[{"account":"rsNvoAZ9MquZSRhu4cEY9wTv1VqHXpVPPt","oracle_document_id":1}],"ledger_index":"validated"} to wss://mainnet.xrpl.validationcloud.io/v1/<YOUR_API_KEY_HERE>.

The oracle in this example is the Band Protocol price feed on mainnet. Use ledger_entry with an oracle selector to inspect the assets an oracle publishes before aggregating. Oracle accounts that fail address validation return invalidParams; a valid account with no such oracle returns objectNotFound.

Last updated

Was this helpful?