#[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
impl PriceFeed
Sourcepub 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
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
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_prev_price_unchecked(&self) -> (Price, i64)
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
impl BorshDeserialize for PriceFeed
Source§impl BorshSerialize for PriceFeed
impl BorshSerialize for PriceFeed
Source§impl<'de> Deserialize<'de> for PriceFeed
impl<'de> Deserialize<'de> for PriceFeed
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PriceFeed, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PriceFeed, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for PriceFeed
impl JsonSchema for PriceFeed
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more