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
Copy file name to clipboardExpand all lines: pyth-sdk/README.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,47 +5,46 @@ This crate is typically used in combination with a platform-specific crate such
5
5
6
6
## Usage
7
7
8
-
The Pyth Network SDK has two core data types:
8
+
The SDK has two core data types:
9
9
10
10
*`PriceFeed` is a container for all currently-available pricing information about a product (e.g., BTC/USD).
11
11
*`Price` represents a price with a degree of uncertainty.
12
12
13
13
The typical usage of this SDK is to first retrieve a `PriceFeed` for one or more products required by your application.
14
-
This step typically uses one of the platform-specific crates referenced above, which provide retrieval methods for specific blockchains.
14
+
This step typically uses one of the platform-specific crates (referenced above), which provide retrieval methods for specific blockchains.
15
15
Once you have a `PriceFeed`, you can call one of the methods below to get the prices your application needs:
16
16
17
17
### Get the Current Price
18
18
19
19
Get the current price of the product from its `PriceFeed`:
20
20
21
21
```rust
22
-
letcurrent_price:Price=price_feed.get_current_price().ok_or(StdError::not_found("Current Price is not available"))?;
22
+
letcurrent_price:Price=price_feed.get_current_price().ok_or(StdError::not_found("Current price is not available"))?;
23
23
println!("price: ({} +- {}) x 10^{}", current_price.price, current_price.conf, current_price.expo);
24
24
```
25
25
26
26
The price is returned along with a confidence interval that represents the degree of uncertainty in the price.
27
27
Both values are represented as fixed-point numbers, `a * 10^e`.
28
-
The method will return `None` if the price is not currently available; this can happen for various reasons, e.g., US equities only trade during market hours.
28
+
The method will return `None` if the current price is not available.
29
29
30
-
Please see the [consumer best practices guide](https://docs.pyth.network/consumers/best-practices) for additional recommendations on how to consume Pyth Network prices, such as how to use the confidence interval.
30
+
Please see the [consumer best practices guide](https://docs.pyth.network/consumers/best-practices) for additional recommendations on how to consume Pyth Network prices, such as how to use the confidence interval, and what to do if the price is not currently available.
31
31
32
32
### EMA Price
33
33
34
34
`PriceFeed` includes an exponentially-weighted moving average (EMA) price that represents a time-average of recent prices.
35
35
The EMA price can be retrieved as follows:
36
36
37
37
```rust
38
-
letcurrent_price:Price=price_feed.get_ema_price().ok_or(StdError::not_found("Current Price is not available"))?;
39
-
println!("price: ({} +- {}) x 10^{}", current_price.price, current_price.conf, current_price.expo);
38
+
letema_price:Price=price_feed.get_ema_price().ok_or(StdError::not_found("EMA price is not available"))?;
39
+
println!("price: ({} +- {}) x 10^{}", ema_price.price, ema_price.conf, ema_price.expo);
40
40
```
41
41
42
-
## Prices
42
+
## Manipulating Prices
43
43
44
-
The `Price` object supports arithmetic operations (e.g., multiplication).
45
-
These operations automatically propagate any uncertainty in the inputs into uncertainty in the output.
46
-
These operations allow you to combine prices in several useful ways:
44
+
The `Price` struct supports arithmetic operations that allow you to combine prices from multiple products.
45
+
These operations can be used to price some products that aren't directly listed on Pyth Network:
47
46
48
-
### Change the Quote Currency
47
+
### Non-USD Prices
49
48
50
49
Most assets listed on Pyth Network are quoted in terms of USD, e.g., the BTC/USD price feed provides the number of dollars per BTC.
51
50
However, some applications would like prices in other quote currencies, such as the number of ETH per BTC.
0 commit comments