Get EMA Price Unsafe
Get the latest exponentially-weighted moving average (EMA) price and confidence interval for the requested price feed id.
The price feed id is a 32-byte id written as a hexadecimal string; see the price feed ids (opens in a new tab) page to look up the id for a given symbol.
The returned price and confidence are decimal numbers written in the form a * 10^e
, where e
is an exponent included in the result.
For example, a price of 1234 with an exponent of -2 represents the number 12.34.
The result also includes a timestamp
which is the unix timestamp for the price update.
The EMA methodology is described in more detail in this blog post (opens in a new tab).
This function may return a price from arbitrarily far in the past.
It is the caller's responsibility to check the returned timestamp
to ensure that the update is recent enough for their use case.
Users of this method will typically invoke update_price_feeds to update the on-chain price before reading it. This step ensures that the on-chain price is fresh.
Argument | Input | Description |
---|---|---|
price_identifier* hex | The ID of the price feed you want to read |
Example Code
use pyth::pyth;
use pyth::price_identifier;
pyth::get_ema_price_unsafe(price_identifier::from_byte_vec(x"<price_identifier>"));