#[non_exhaustive]pub struct DerivativesTick {
pub funding_rate: f64,
pub mark_price: f64,
pub index_price: f64,
pub futures_price: f64,
pub open_interest: f64,
pub long_size: f64,
pub short_size: f64,
pub taker_buy_volume: f64,
pub taker_sell_volume: f64,
pub long_liquidation: f64,
pub short_liquidation: f64,
pub timestamp: i64,
}Expand description
A single derivatives / perpetual-futures market tick.
Field invariants enforced by new:
funding_rateis finite and may be negative (a negative funding rate means shorts pay longs).mark_price,index_priceandfutures_priceare finite and strictly positive.open_interest,long_size,short_size,taker_buy_volume,taker_sell_volume,long_liquidationandshort_liquidationare finite and non-negative.
timestamp is a caller-defined epoch / resolution and is not validated.
§Construction and the limits of its guarantee
The struct is #[non_exhaustive], so code outside this crate cannot build
one from a field literal and must go through new, which
validates, or new_unchecked, which is an explicit
opt-out for values already known to be sound.
The fields stay public because reading them is by far the common operation
and an accessor on each would buy nothing. That does mean a validated value
can still be written into an invalid state afterwards, and nothing detects
it: the indicators that consume this type rely on the constructor’s
guarantee rather than re-checking every bar. Treat a mutation the way you
would treat new_unchecked — you are asserting the invariants still hold.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.funding_rate: f64Current funding rate for the interval (finite; may be negative).
mark_price: f64Perpetual mark price (finite, strictly positive).
index_price: f64Spot / index price the perpetual tracks (finite, strictly positive).
futures_price: f64Dated (e.g. quarterly) futures mark price (finite, strictly positive).
open_interest: f64Open interest — outstanding contracts / notional (finite, non-negative).
long_size: f64Aggregate long size / long account count (finite, non-negative).
short_size: f64Aggregate short size / short account count (finite, non-negative).
taker_buy_volume: f64Taker buy (ask-lifting) volume (finite, non-negative).
taker_sell_volume: f64Taker sell (bid-hitting) volume (finite, non-negative).
long_liquidation: f64Long-side liquidation notional (finite, non-negative).
short_liquidation: f64Short-side liquidation notional (finite, non-negative).
timestamp: i64Tick timestamp (caller-defined epoch / resolution).
Implementations§
Source§impl DerivativesTick
impl DerivativesTick
Sourcepub fn new(
funding_rate: f64,
mark_price: f64,
index_price: f64,
futures_price: f64,
open_interest: f64,
long_size: f64,
short_size: f64,
taker_buy_volume: f64,
taker_sell_volume: f64,
long_liquidation: f64,
short_liquidation: f64,
timestamp: i64,
) -> Result<Self>
pub fn new( funding_rate: f64, mark_price: f64, index_price: f64, futures_price: f64, open_interest: f64, long_size: f64, short_size: f64, taker_buy_volume: f64, taker_sell_volume: f64, long_liquidation: f64, short_liquidation: f64, timestamp: i64, ) -> Result<Self>
Construct a derivatives tick, validating every field invariant.
§Errors
Returns Error::InvalidDerivatives if funding_rate is not finite;
any of mark_price, index_price, futures_price is not a finite
positive number; or any of the six size / volume / liquidation fields is
not a finite non-negative number.
Sourcepub const fn new_unchecked(
funding_rate: f64,
mark_price: f64,
index_price: f64,
futures_price: f64,
open_interest: f64,
long_size: f64,
short_size: f64,
taker_buy_volume: f64,
taker_sell_volume: f64,
long_liquidation: f64,
short_liquidation: f64,
timestamp: i64,
) -> Self
pub const fn new_unchecked( funding_rate: f64, mark_price: f64, index_price: f64, futures_price: f64, open_interest: f64, long_size: f64, short_size: f64, taker_buy_volume: f64, taker_sell_volume: f64, long_liquidation: f64, short_liquidation: f64, timestamp: i64, ) -> Self
Construct a derivatives tick without validation. The caller asserts that
every field invariant documented on DerivativesTick holds.
Trait Implementations§
Source§impl Clone for DerivativesTick
impl Clone for DerivativesTick
Source§fn clone(&self) -> DerivativesTick
fn clone(&self) -> DerivativesTick
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DerivativesTick
Source§impl Debug for DerivativesTick
impl Debug for DerivativesTick
Source§impl PartialEq for DerivativesTick
impl PartialEq for DerivativesTick
impl StructuralPartialEq for DerivativesTick
Auto Trait Implementations§
impl Freeze for DerivativesTick
impl RefUnwindSafe for DerivativesTick
impl Send for DerivativesTick
impl Sync for DerivativesTick
impl Unpin for DerivativesTick
impl UnsafeUnpin for DerivativesTick
impl UnwindSafe for DerivativesTick
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