pub struct HyperliquidAccountState {
pub balances: AHashMap<String, HyperliquidBalance>,
pub last_sequence: u64,
}Expand description
Simplified account state for Hyperliquid adapter.
This tracks only the essential state needed for generating Nautilus AccountState events. Position tracking is handled by the Nautilus platform, not the adapter.
See Hyperliquid API documentation:
Fields§
§balances: AHashMap<String, HyperliquidBalance>§last_sequence: u64Implementations§
Source§impl HyperliquidAccountState
impl HyperliquidAccountState
pub fn new() -> Self
Sourcepub fn get_balance(&self, asset: &str) -> HyperliquidBalance
pub fn get_balance(&self, asset: &str) -> HyperliquidBalance
Get balance for an asset, returns zero balance if not found
Sourcepub fn account_value(&self) -> Decimal
pub fn account_value(&self) -> Decimal
Calculate total account value from balances only. Note: This doesn’t include unrealized PnL from positions as those are tracked by the Nautilus platform, not the adapter.
Sourcepub fn to_account_state(
&self,
account_id: AccountId,
ts_event: UnixNanos,
ts_init: UnixNanos,
) -> Result<AccountState>
pub fn to_account_state( &self, account_id: AccountId, ts_event: UnixNanos, ts_init: UnixNanos, ) -> Result<AccountState>
Convert HyperliquidAccountState to Nautilus AccountState event.
This creates a standard Nautilus AccountState from the Hyperliquid-specific account state, converting balances and handling the margin account type since Hyperliquid supports leverage.
§Returns
A Nautilus AccountState event that can be processed by the platform
Source§impl HyperliquidAccountState
impl HyperliquidAccountState
Sourcepub fn apply(&mut self, event: HyperliquidAccountEvent)
pub fn apply(&mut self, event: HyperliquidAccountEvent)
Apply a balance event to update the account state
Trait Implementations§
Source§impl Debug for HyperliquidAccountState
impl Debug for HyperliquidAccountState
Source§impl Default for HyperliquidAccountState
impl Default for HyperliquidAccountState
Source§fn default() -> HyperliquidAccountState
fn default() -> HyperliquidAccountState
Auto Trait Implementations§
impl Freeze for HyperliquidAccountState
impl RefUnwindSafe for HyperliquidAccountState
impl Send for HyperliquidAccountState
impl Sync for HyperliquidAccountState
impl Unpin for HyperliquidAccountState
impl UnsafeUnpin for HyperliquidAccountState
impl UnwindSafe for HyperliquidAccountState
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> 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