pub struct AssetState {
pub asset: Asset,
pub statistics: TearSheetAssetGenerator,
pub balance: Option<Timed<Balance>>,
}Expand description
Represents the current state of an asset, including its Balance and last update
time_exchange.
When used in the context of AssetStates, this state is for an exchange asset, but it could
be used for a “global” asset that aggregates data for similar named assets on multiple
exchanges.
Fields§
§asset: AssetAsset name data that details the internal and exchange names.
statistics: TearSheetAssetGeneratorTearSheet generator for summarising trading session changes the asset.
balance: Option<Timed<Balance>>Current balance of the asset and associated exchange timestamp.
Implementations§
Source§impl AssetState
impl AssetState
pub const fn new( asset: Asset, statistics: TearSheetAssetGenerator, balance: Option<Timed<Balance>>, ) -> AssetState
Source§impl AssetState
impl AssetState
Sourcepub fn update_from_balance<AssetKey>(
&mut self,
snapshot: Snapshot<&AssetBalance<AssetKey>>,
)
pub fn update_from_balance<AssetKey>( &mut self, snapshot: Snapshot<&AssetBalance<AssetKey>>, )
Updates the AssetState from an AssetBalance snapshot, if the snapshot is more recent.
This method ensures temporal consistency by only applying updates from snapshots that are at least as recent as the current state.
Sourcepub fn apply_balance_update<AssetKey>(
&mut self,
snapshot: Snapshot<&AssetBalanceUpdate<AssetKey>>,
)
pub fn apply_balance_update<AssetKey>( &mut self, snapshot: Snapshot<&AssetBalanceUpdate<AssetKey>>, )
Applies a WS partial AssetBalanceUpdate (free/locked only), if more recent.
Updates free and recomputes total = free + locked, while preserving any existing
MarginDetails — a stream update carries no
debt, so this path structurally cannot clobber known borrowed/interest. On a cold start
(no prior balance) the merged balance has margin: None, consistent with the debt-freshness
contract (debt becomes known only via a BalanceSnapshot).
Like Self::update_from_balance, stale updates (older than the current state) are ignored.
Trait Implementations§
Source§impl Clone for AssetState
impl Clone for AssetState
Source§fn clone(&self) -> AssetState
fn clone(&self) -> AssetState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AssetState
impl Debug for AssetState
Source§impl<'de> Deserialize<'de> for AssetState
impl<'de> Deserialize<'de> for AssetState
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>,
Source§impl From<&AssetState> for AssetBalance<AssetNameExchange>
impl From<&AssetState> for AssetBalance<AssetNameExchange>
Source§fn from(value: &AssetState) -> Self
fn from(value: &AssetState) -> Self
Source§impl PartialEq for AssetState
impl PartialEq for AssetState
Source§fn eq(&self, other: &AssetState) -> bool
fn eq(&self, other: &AssetState) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for AssetState
impl PartialOrd for AssetState
Source§impl Serialize for AssetState
impl Serialize for AssetState
impl StructuralPartialEq for AssetState
Auto Trait Implementations§
impl Freeze for AssetState
impl RefUnwindSafe for AssetState
impl Send for AssetState
impl Sync for AssetState
impl Unpin for AssetState
impl UnsafeUnpin for AssetState
impl UnwindSafe for AssetState
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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