Struct pyth_sdk_solana::PriceFeed
source · pub struct PriceFeed {
pub id: Identifier,
/* private fields */
}
Expand description
Represents a current aggregation price from pyth publisher feeds.
Fields§
§id: Identifier
Unique identifier for this price.
Implementations§
source§impl PriceFeed
impl PriceFeed
sourcepub fn new(id: Identifier, price: Price, ema_price: Price) -> PriceFeed
pub fn new(id: Identifier, price: Price, ema_price: Price) -> PriceFeed
Constructs a new Price Feed
sourcepub fn get_price_unchecked(&self) -> Price
pub fn get_price_unchecked(&self) -> Price
Get the “unchecked” price and confidence interval as fixed-point numbers of the form a * 10^e along with its publish time.
Returns a Price
struct containing the current price, confidence interval, and the exponent
for both numbers, and publish time. This method returns the latest price which may be from
arbitrarily far in the past, and the caller should probably check the timestamp before using
it.
Please consider using get_price_no_older_than
when possible.
sourcepub fn get_ema_price_unchecked(&self) -> Price
pub fn get_ema_price_unchecked(&self) -> Price
Get the “unchecked” exponentially-weighted moving average (EMA) price and a confidence interval on the result along with its publish time.
Returns the latest EMA price value which may be from arbitrarily far in the past, and the caller should probably check the timestamp before using it.
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.
Please consider using get_ema_price_no_older_than
when possible.
sourcepub fn get_price_no_older_than(
&self,
current_time: i64,
age: u64
) -> Option<Price>
pub fn get_price_no_older_than(
&self,
current_time: i64,
age: u64
) -> Option<Price>
Get the price as long as it was updated within age
seconds of the
current_time
.
This function is a sanity-checked version of get_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 age
seconds of the
current_time
.
sourcepub fn get_ema_price_no_older_than(
&self,
current_time: i64,
age: u64
) -> Option<Price>
pub fn get_ema_price_no_older_than(
&self,
current_time: i64,
age: u64
) -> Option<Price>
Get the exponentially-weighted moving average (EMA) price as long as it was updated within
age
seconds of the current_time
.
This function is a sanity-checked version of get_ema_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 EMA price, confidence interval and the exponent
for both numbers, or None
if no price update occurred within age
seconds of the
current_time
.
Trait Implementations§
source§impl BorshDeserialize for PriceFeedwhere
Identifier: BorshDeserialize,
Price: BorshDeserialize,
impl BorshDeserialize for PriceFeedwhere
Identifier: BorshDeserialize,
Price: BorshDeserialize,
source§impl BorshSerialize for PriceFeedwhere
Identifier: BorshSerialize,
Price: BorshSerialize,
impl BorshSerialize for PriceFeedwhere
Identifier: BorshSerialize,
Price: BorshSerialize,
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 json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more