Struct pyth_sdk_solana::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
sourceimpl 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_latest_available_price_unchecked(&self) -> (Price, i64)
pub fn get_latest_available_price_unchecked(&self) -> (Price, i64)
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: i64,
duration: u64
) -> Option<Price>
pub fn get_latest_available_price_within_duration(
&self,
current_time: i64,
duration: u64
) -> 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
Identifier: BorshDeserialize,
PriceStatus: BorshDeserialize,
i64: BorshDeserialize,
i32: BorshDeserialize,
u32: BorshDeserialize,
u64: BorshDeserialize,
impl BorshDeserialize for PriceFeed where
Identifier: BorshDeserialize,
PriceStatus: BorshDeserialize,
i64: BorshDeserialize,
i32: BorshDeserialize,
u32: BorshDeserialize,
u64: BorshDeserialize,
sourceimpl BorshSerialize for PriceFeed where
Identifier: BorshSerialize,
PriceStatus: BorshSerialize,
i64: BorshSerialize,
i32: BorshSerialize,
u32: BorshSerialize,
u64: BorshSerialize,
impl BorshSerialize for PriceFeed where
Identifier: BorshSerialize,
PriceStatus: BorshSerialize,
i64: BorshSerialize,
i32: BorshSerialize,
u32: BorshSerialize,
u64: BorshSerialize,
sourceimpl<'de> Deserialize<'de> for PriceFeed
impl<'de> Deserialize<'de> for PriceFeed
sourcefn 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>,
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
fn 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
sourceimpl PartialEq<PriceFeed> for PriceFeed
impl PartialEq<PriceFeed> for PriceFeed
sourceimpl Serialize for PriceFeed
impl Serialize for PriceFeed
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
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
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
impl<T> AbiEnumVisitor for T where
T: Serialize + ?Sized,
impl<T> AbiEnumVisitor for T where
T: Serialize + ?Sized,
default fn visit_for_abi(
&self,
_digester: &mut AbiDigester
) -> Result<AbiDigester, DigestError>
impl<T> AbiEnumVisitor for T where
T: Serialize + AbiExample + ?Sized,
impl<T> AbiEnumVisitor for T where
T: Serialize + AbiExample + ?Sized,
default fn visit_for_abi(
&self,
digester: &mut AbiDigester
) -> Result<AbiDigester, DigestError>
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
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