pub struct PriceConf {
    pub price: i64,
    pub conf: u64,
    pub expo: i32,
}
👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

Expand description

A price with a degree of uncertainty, represented as a price +- a confidence interval. The confidence interval roughly corresponds to the standard error of a normal distribution. Both the price and confidence are stored in a fixed-point numeric representation, x * 10^expo, where expo is the exponent. For example:

use pyth_client::PriceConf;
PriceConf { price: 12345, conf: 267, expo: -2 }; // represents 123.45 +- 2.67
PriceConf { price: 123, conf: 1, expo: 2 }; // represents 12300 +- 100

PriceConf supports a limited set of mathematical operations. All of these operations will propagate any uncertainty in the arguments into the result. However, the uncertainty in the result may overestimate the true uncertainty (by at most a factor of sqrt(2)) due to computational limitations. Furthermore, all of these operations may return None if their result cannot be represented within the numeric representation (e.g., the exponent is so small that the price does not fit into an i64). Users of these methods should (1) select their exponents to avoid this problem, and (2) handle the None case gracefully.

Fields

price: i64
👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

conf: u64
👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

expo: i32
👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

Implementations

👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

Divide this price by other while propagating the uncertainty in both prices into the result.

This method will automatically select a reasonable exponent for the result. If both self and other are normalized, the exponent is self.expo + PD_EXPO - other.expo (i.e., the fraction has PD_EXPO digits of additional precision). If they are not normalized, this method will normalize them, resulting in an unpredictable result exponent. If the result is used in a context that requires a specific exponent, please call scale_to_exponent on it.

👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

Add other to this, propagating uncertainty in both prices. Requires both PriceConfs to have the same exponent – use scale_to_exponent on the arguments if necessary.

TODO: could generalize this method to support different exponents.

👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

Multiply this PriceConf by a constant c * 10^e.

👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

Multiply this PriceConf by other, propagating any uncertainty.

👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

Get a copy of this struct where the price and confidence have been normalized to be between MIN_PD_V_I64 and MAX_PD_V_I64.

👎 Deprecated:

This crate has been deprecated. Please use pyth-sdk-solana instead.

Scale this price/confidence so that its exponent is target_expo. Return None if this number is outside the range of numbers representable in target_expo, which will happen if target_expo is too small.

Warning: if target_expo is significantly larger than the current exponent, this function will return 0 +- 0.

Trait Implementations

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes. Read more

Deserialize this instance from a slice of bytes.

Serialize this instance into a vector of bytes.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.