pub struct PriceFeed(/* private fields */);
Methods from Deref<Target = PriceFeed>§
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 AccountDeserialize for PriceFeed
impl AccountDeserialize for PriceFeed
Source§fn try_deserialize_unchecked(data: &mut &[u8]) -> Result<Self>
fn try_deserialize_unchecked(data: &mut &[u8]) -> Result<Self>
Source§fn try_deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn try_deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Mint
account into a token
Account
.Source§impl AccountSerialize for PriceFeed
impl AccountSerialize for PriceFeed
Auto Trait Implementations§
impl Freeze for PriceFeed
impl RefUnwindSafe for PriceFeed
impl Send for PriceFeed
impl Sync for PriceFeed
impl Unpin for PriceFeed
impl UnwindSafe for PriceFeed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more