Struct PriceFeed

Source
#[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§

Source§

impl PriceFeed

Source

pub fn new( id: Identifier, status: PriceStatus, publish_time: i64, expo: i32, max_num_publishers: u32, num_publishers: u32, product_id: Identifier, price: i64, conf: u64, ema_price: i64, ema_conf: u64, prev_price: i64, prev_conf: u64, prev_publish_time: i64, ) -> PriceFeed

Constructs a new Price Feed

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_prev_price_unchecked(&self) -> (Price, i64)

Get the “unchecked” previous price with Trading status, along with the timestamp at which it was generated.

WARNING: We make no guarantees about the unchecked price and confidence returned by this function: it could differ significantly from the current price. We strongly encourage you to use get_current_price instead.

Trait Implementations§

Source§

impl BorshDeserialize for PriceFeed

Source§

fn deserialize(buf: &mut &[u8]) -> Result<PriceFeed, Error>

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

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

impl BorshSerialize for PriceFeed

Source§

fn serialize<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write,

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl Clone for PriceFeed

Source§

fn clone(&self) -> PriceFeed

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PriceFeed

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for PriceFeed

Source§

fn default() -> PriceFeed

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

impl<'de> Deserialize<'de> for PriceFeed

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<PriceFeed, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for PriceFeed

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

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

impl PartialEq for PriceFeed

Source§

fn eq(&self, other: &PriceFeed) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PriceFeed

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for PriceFeed

Source§

impl Eq for PriceFeed

Source§

impl StructuralPartialEq for PriceFeed

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,