pub struct SpotBalance {
pub coin: Ustr,
pub token: u32,
pub total: Decimal,
pub hold: Decimal,
pub entry_ntl: Option<Decimal>,
}Expand description
A single token balance entry from spotClearinghouseState.balances.
Fields§
§coin: UstrToken name (e.g., “USDC”, “PURR”).
token: u32Token index matching spotMeta.tokens[*].index.
total: DecimalTotal token balance (on-hold plus available).
hold: DecimalPortion currently reserved for resting orders.
entry_ntl: Option<Decimal>Entry notional value (position cost basis in USDC).
Implementations§
Source§impl SpotBalance
impl SpotBalance
Sourcepub fn free(&self) -> Decimal
pub fn free(&self) -> Decimal
Returns the balance freely available to trade or withdraw (total - hold).
Sourcepub fn avg_entry_px(&self) -> Option<Decimal>
pub fn avg_entry_px(&self) -> Option<Decimal>
Returns the average entry price derived from entry_ntl / total, if both are non-zero.
Trait Implementations§
Source§impl Clone for SpotBalance
impl Clone for SpotBalance
Source§fn clone(&self) -> SpotBalance
fn clone(&self) -> SpotBalance
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SpotBalance
impl Debug for SpotBalance
Source§impl<'de> Deserialize<'de> for SpotBalance
impl<'de> Deserialize<'de> for SpotBalance
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SpotBalance
impl RefUnwindSafe for SpotBalance
impl Send for SpotBalance
impl Sync for SpotBalance
impl Unpin for SpotBalance
impl UnsafeUnpin for SpotBalance
impl UnwindSafe for SpotBalance
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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