#[repr(C)]pub struct PriceFeed {
pub id: PriceIdentifier,
pub status: PriceStatus,
pub publish_time: UnixTimestamp,
pub expo: i32,
pub max_num_publishers: u32,
pub num_publishers: u32,
pub product_id: ProductIdentifier,
/* private fields */
}Expand description
Represents a current aggregation price from pyth publisher feeds.
Fields
id: PriceIdentifierUnique identifier for this price.
status: PriceStatusStatus of price (Trading is valid).
publish_time: UnixTimestampCurrent price aggregation publish time
expo: i32Price exponent.
max_num_publishers: u32Maximum number of allowed publishers that can contribute to a price.
num_publishers: u32Number of publishers that made up current aggregate.
product_id: ProductIdentifierProduct account key.
Implementations
sourceimpl PriceFeed
impl PriceFeed
sourcepub fn new(
id: PriceIdentifier,
status: PriceStatus,
publish_time: UnixTimestamp,
expo: i32,
max_num_publishers: u32,
num_publishers: u32,
product_id: ProductIdentifier,
price: i64,
conf: u64,
ema_price: i64,
ema_conf: u64,
prev_price: i64,
prev_conf: u64,
prev_publish_time: UnixTimestamp
) -> PriceFeed
pub fn new(
id: PriceIdentifier,
status: PriceStatus,
publish_time: UnixTimestamp,
expo: i32,
max_num_publishers: u32,
num_publishers: u32,
product_id: ProductIdentifier,
price: i64,
conf: u64,
ema_price: i64,
ema_conf: u64,
prev_price: i64,
prev_conf: u64,
prev_publish_time: UnixTimestamp
) -> PriceFeed
Constructs a new Price Feed
sourcepub fn get_current_price(&self) -> Option<Price>
pub fn get_current_price(&self) -> Option<Price>
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.
sourcepub fn get_current_price_unchecked(&self) -> Price
pub fn get_current_price_unchecked(&self) -> Price
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.
sourcepub fn get_ema_price(&self) -> Option<Price>
pub fn get_ema_price(&self) -> Option<Price>
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.
sourcepub fn get_ema_price_unchecked(&self) -> Price
pub fn get_ema_price_unchecked(&self) -> Price
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.
sourcepub fn get_latest_available_price_unchecked(&self) -> (Price, UnixTimestamp)
pub fn get_latest_available_price_unchecked(&self) -> (Price, UnixTimestamp)
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.
sourcepub fn get_latest_available_price_within_duration(
&self,
current_time: UnixTimestamp,
duration: DurationInSeconds
) -> Option<Price>
pub fn get_latest_available_price_within_duration(
&self,
current_time: UnixTimestamp,
duration: DurationInSeconds
) -> Option<Price>
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
sourceimpl BorshDeserialize for PriceFeed where
PriceIdentifier: BorshDeserialize,
PriceStatus: BorshDeserialize,
UnixTimestamp: BorshDeserialize,
i32: BorshDeserialize,
u32: BorshDeserialize,
u32: BorshDeserialize,
ProductIdentifier: BorshDeserialize,
i64: BorshDeserialize,
u64: BorshDeserialize,
i64: BorshDeserialize,
u64: BorshDeserialize,
i64: BorshDeserialize,
u64: BorshDeserialize,
UnixTimestamp: BorshDeserialize,
impl BorshDeserialize for PriceFeed where
PriceIdentifier: BorshDeserialize,
PriceStatus: BorshDeserialize,
UnixTimestamp: BorshDeserialize,
i32: BorshDeserialize,
u32: BorshDeserialize,
u32: BorshDeserialize,
ProductIdentifier: BorshDeserialize,
i64: BorshDeserialize,
u64: BorshDeserialize,
i64: BorshDeserialize,
u64: BorshDeserialize,
i64: BorshDeserialize,
u64: BorshDeserialize,
UnixTimestamp: BorshDeserialize,
sourceimpl BorshSerialize for PriceFeed where
PriceIdentifier: BorshSerialize,
PriceStatus: BorshSerialize,
UnixTimestamp: BorshSerialize,
i32: BorshSerialize,
u32: BorshSerialize,
u32: BorshSerialize,
ProductIdentifier: BorshSerialize,
i64: BorshSerialize,
u64: BorshSerialize,
i64: BorshSerialize,
u64: BorshSerialize,
i64: BorshSerialize,
u64: BorshSerialize,
UnixTimestamp: BorshSerialize,
impl BorshSerialize for PriceFeed where
PriceIdentifier: BorshSerialize,
PriceStatus: BorshSerialize,
UnixTimestamp: BorshSerialize,
i32: BorshSerialize,
u32: BorshSerialize,
u32: BorshSerialize,
ProductIdentifier: BorshSerialize,
i64: BorshSerialize,
u64: BorshSerialize,
i64: BorshSerialize,
u64: BorshSerialize,
i64: BorshSerialize,
u64: BorshSerialize,
UnixTimestamp: BorshSerialize,
sourceimpl<'de> Deserialize<'de> for PriceFeed
impl<'de> Deserialize<'de> for PriceFeed
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl JsonSchema for PriceFeed
impl JsonSchema for PriceFeed
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
impl Copy for PriceFeed
impl Eq for PriceFeed
impl StructuralEq for PriceFeed
impl StructuralPartialEq for PriceFeed
Auto Trait Implementations
impl RefUnwindSafe for PriceFeed
impl Send for PriceFeed
impl Sync for PriceFeed
impl Unpin for PriceFeed
impl UnwindSafe for PriceFeed
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more