You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Get the **last updated** exponentially weighted moving average (EMA) price object for the requested price feed ID. _Caution: This function may return a price arbitrarily in the past_",
8
8
description: `
9
-
Get the latest exponentially-weighted moving average (EMA) price and confidence
10
-
interval for the requested price feed id. The price feed id is a 32-byte id
11
-
written as a hexadecimal string; see the [price feed
12
-
ids](https://pyth.network/developers/price-feed-ids) page to look up the id for
13
-
a given symbol. The returned price and confidence are decimal numbers written
14
-
in the form \`a * 10^e\`, where \`e\` is an exponent included in the result.
15
-
For example, a price of 1234 with an exponent of -2 represents the number 12.34.
16
-
The result also includes a \`publishTime\` which is the unix timestamp for the
17
-
price update. The EMA methodology is described in more detail in this [blog
This method returns the price object containing **last updated** exponentially-weighted moving average(EMA) price for the requested price feed ID.
19
10
20
-
**This function may return a price from arbitrarily far in the past.** It is the
21
-
caller's responsibility to check the returned \`publishTime\` to ensure that the
22
-
update is recent enough for their use case.
11
+
**This function may return a price from arbitrarily far in the past.** It is the
12
+
caller's responsibility to check the returned \`publishTime\` to ensure that the
13
+
update is recent enough for their use case. If you need the latest price, update the price using [\`updatePriceFeeds()\`](updatePriceFeeds) and then call [\`getEmaPrice()\`](getEmaPrice).
23
14
24
-
This function reverts with a \`PriceFeedNotFound\` error if the requested feed
25
-
id has never received a price update. This error could either mean that the
26
-
provided price feed id is incorrect, or (more typically) that this is the first
27
-
attempted use of that feed on-chain. In the second case, calling
28
-
[updatePriceFeeds](updatePriceFeeds) will solve this problem.
15
+
The price object contains the following fields:
16
+
1. \`price\`: The latest price of the price feed.
17
+
2. \`conf\`: The confidence level of the price feed.
18
+
3. \`expo\`: The exponent of the price feed.
19
+
4. \`publishtime\`: The time when the price feed was last updated.
20
+
21
+
Sample \`price\` object:
22
+
\`\`\`json
23
+
{
24
+
price: 123456789n,
25
+
conf: 180726074n,
26
+
expo: -8,
27
+
publishTime: 1721765108n
28
+
}
29
+
\`\`\`
30
+
31
+
The \`price\` above is in the format of \`price * 10^expo\`. So, the \`price\` in above
32
+
mentioned sample represents the number \`123456789 * 10(-8) = 1.23456789\` in
33
+
this case.
34
+
35
+
### Error Response
36
+
37
+
The above method can return the following error response:
38
+
- \`StalePrice\`: The on-chain price has not been updated within the last
"Get the **last updated** price object for the requested price feed ID. _Caution: This function may return a price from arbitrarily in the the past_",
8
8
description: `
9
-
Get the latest price and confidence interval for the requested price feed id.
10
-
The price feed id is a 32-byte id written as a hexadecimal string; see the
11
-
[price feed ids](https://pyth.network/developers/price-feed-ids) page to look up
12
-
the id for a given symbol. The returned price and confidence are decimal numbers
13
-
written in the form \`a * 10^e\`, where \`e\` is an exponent included in the
14
-
result. For example, a price of 1234 with an exponent of -2 represents the
15
-
number 12.34. The result also includes a \`publishTime\` which is the unix
16
-
timestamp for the price update.
9
+
This method returns the price object containing **last updated** price for the requested price feed ID.
17
10
18
-
**This function may return a price from arbitrarily far in the past.** It is the
19
-
caller's responsibility to check the returned \`publishTime\` to ensure that the
20
-
update is recent enough for their use case.
11
+
**This function may return a price from arbitrarily far in the past.** It is the
12
+
caller's responsibility to check the returned \`publishTime\` to ensure that the
13
+
update is recent enough for their use case. If you need the latest price, update the price using [\`updatePriceFeeds()\`](updatePriceFeeds) and then call [\`getPrice()\`](getPrice).
21
14
22
-
This function reverts with a \`PriceFeedNotFound\` error if the requested feed
23
-
id has never received a price update. This error could either mean that the
24
-
provided price feed id is incorrect, or (more typically) that this is the first
25
-
attempted use of that feed on-chain. In the second case, calling
26
-
[updatePriceFeeds](updatePriceFeeds) will solve this problem.
27
-
`,
15
+
The price object contains the following fields:
16
+
1. \`price\`: The latest price of the price feed.
17
+
2. \`conf\`: The confidence level of the price feed.
18
+
3. \`expo\`: The exponent of the price feed.
19
+
4. \`publishtime\`: The time when the price feed was last updated.
20
+
21
+
Sample \`price\` object:
22
+
\`\`\`json
23
+
{
24
+
price: 123456789n,
25
+
conf: 180726074n,
26
+
expo: -8,
27
+
publishTime: 1721765108n
28
+
}
29
+
\`\`\`
30
+
31
+
The \`price\` above is in the format of \`price * 10^expo\`. So, the \`price\` in above
32
+
mentioned sample represents the number \`123456789 * 10(-8) = 1.23456789\` in
33
+
this case.
34
+
35
+
### Error Response
36
+
37
+
The above method can return the following error response:
38
+
- \`StalePrice\`: The on-chain price has not been updated within the last
0 commit comments