#[repr(C)]
pub struct PriceFeed { pub id: Identifier, pub status: PriceStatus, pub publish_time: i64, pub expo: i32, pub max_num_publishers: u32, pub num_publishers: u32, pub product_id: Identifier, /* private fields */ }
Expand description

Represents a current aggregation price from pyth publisher feeds.

Fields

id: Identifier

Unique identifier for this price.

status: PriceStatus

Status of price (Trading is valid).

publish_time: i64

Current price aggregation publish time

expo: i32

Price exponent.

max_num_publishers: u32

Maximum number of allowed publishers that can contribute to a price.

num_publishers: u32

Number of publishers that made up current aggregate.

product_id: Identifier

Product account key.

Implementations

Constructs a new Price Feed

Get the current price and confidence interval as fixed-point numbers of the form a * 10^e.

Returns a struct containing the current price, confidence interval, and the exponent for both numbers. Returns None if price information is currently unavailable for any reason.

Get the “unchecked” current price and confidence interval as fixed-point numbers of the form a * 10^e.

Returns a struct containing the current price, confidence interval, and the exponent for both numbers. This method returns the price value without checking availability of the price. This value might not be valid or updated when the price is not available. Please use get_current_price where possible.

Get the exponential moving average price (ema_price) and a confidence interval on the result.

Returns None if the ema price is currently unavailable. At the moment, the confidence interval returned by this method is computed in a somewhat questionable way, so we do not recommend using it for high-value applications.

Get the “unchecked” exponential moving average price (ema_price) and a confidence interval on the result.

Returns the price value without checking availability of the price. This value might not be valid or updated when the price is not available. Please use get_ema_price where possible.

At the moment, the confidence interval returned by this method is computed in a somewhat questionable way, so we do not recommend using it for high-value applications.

Get the latest available price, along with the timestamp when it was generated.

This function returns the same price as get_current_price in the case where a price was available at the time this PriceFeed was published (publish_time). However, if a price was not available at that time, this function returns the price from the latest time at which the price was available. The returned price can be from arbitrarily far in the past; this function makes no guarantees that the returned price is recent or useful for any particular application.

Users of this function should check the returned timestamp to ensure that the returned price is sufficiently recent for their application. If you are considering using this function, it may be safer / easier to use either get_current_price or get_latest_available_price_within_duration.

Returns a struct containing the latest available price, confidence interval, and the exponent for both numbers along with the timestamp when that price was generated.

Get the latest price as long as it was updated within duration seconds of the current_time.

This function is a sanity-checked version of get_latest_available_price_unchecked which is useful in applications that require a sufficiently-recent price. Returns None if the price wasn’t updated sufficiently recently.

Returns a struct containing the latest available price, confidence interval and the exponent for both numbers, or None if no price update occurred within duration seconds of the current_time.

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

The name of the generated JSON Schema. Read more

Generates a JSON Schema for this type. Read more

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

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.