pub struct ADLAlertUpdate {
pub topic: String,
pub event_type: String,
pub timestamp: u64,
pub data: Vec<ADLAlertWebsocketItem>,
}Expand description
Represents a WebSocket ADL alert update event.
Contains real-time ADL alert information for various trading pairs. Push frequency: 1 second for USDT Perpetual/Delivery, USDC Perpetual/Delivery, and Inverse Contracts.
§Bybit API Reference
Topic: adlAlert.{coin} where coin can be:
adlAlert.USDTfor USDT Perpetual/DeliveryadlAlert.USDCfor USDC Perpetual/DeliveryadlAlert.inversefor Inverse contracts
Fields§
§topic: StringThe WebSocket topic for the event (e.g., “adlAlert.USDT”, “adlAlert.USDC”, “adlAlert.inverse”).
Specifies the data stream for the ADL alert update. Bots use this to determine which contract group the update belongs to.
event_type: StringThe event type (e.g., “snapshot”).
ADL alert updates are typically snapshot type, containing the full current state.
timestamp: u64The timestamp of the event in milliseconds.
Indicates when the ADL alert update was generated by the system. Bots use this to ensure data freshness and time-based analysis.
data: Vec<ADLAlertWebsocketItem>The ADL alert data.
Contains a list of ADL alert items. Each item represents ADL alert information for a specific trading pair.
Implementations§
Source§impl ADLAlertUpdate
impl ADLAlertUpdate
Sourcepub fn contract_group(&self) -> Option<&str>
pub fn contract_group(&self) -> Option<&str>
Returns the contract group from the topic.
Extracts the contract group identifier from the WebSocket topic. Examples:
- “adlAlert.USDT” -> “USDT”
- “adlAlert.USDC” -> “USDC”
- “adlAlert.inverse” -> “inverse”
Sourcepub fn is_snapshot(&self) -> bool
pub fn is_snapshot(&self) -> bool
Returns true if this is a snapshot update.
Snapshot updates contain the full ADL alert state and should replace the local state for the corresponding contract group.
Sourcepub fn timestamp_datetime(&self) -> DateTime<Utc>
pub fn timestamp_datetime(&self) -> DateTime<Utc>
Returns the timestamp as a chrono DateTime.
Sourcepub fn age_ms(&self) -> u64
pub fn age_ms(&self) -> u64
Returns the age of the update in milliseconds.
Calculates how old this update is relative to the current time.
Sourcepub fn is_stale(&self) -> bool
pub fn is_stale(&self) -> bool
Returns true if the update is stale (older than 2 seconds).
Since ADL alert updates are pushed every 1 second, data older than 2 seconds might be considered stale for real-time trading decisions.
Sourcepub fn find_by_symbol(&self, symbol: &str) -> Option<&ADLAlertWebsocketItem>
pub fn find_by_symbol(&self, symbol: &str) -> Option<&ADLAlertWebsocketItem>
Finds an ADL alert item for a specific symbol.
Returns the first matching ADL alert item for the given symbol.
Sourcepub fn filter_by_coin(&self, coin: &str) -> Vec<&ADLAlertWebsocketItem>
pub fn filter_by_coin(&self, coin: &str) -> Vec<&ADLAlertWebsocketItem>
Finds all ADL alert items for a specific coin.
Sourcepub fn triggered_items(&self) -> Vec<&ADLAlertWebsocketItem>
pub fn triggered_items(&self) -> Vec<&ADLAlertWebsocketItem>
Returns all ADL alert items where any ADL condition is triggered.
Sourcepub fn stopped_items(&self) -> Vec<&ADLAlertWebsocketItem>
pub fn stopped_items(&self) -> Vec<&ADLAlertWebsocketItem>
Returns all ADL alert items where all ADL conditions are stopped.
Sourcepub fn count_triggered(&self) -> usize
pub fn count_triggered(&self) -> usize
Returns the number of ADL alert items with triggered conditions.
Sourcepub fn count_stopped(&self) -> usize
pub fn count_stopped(&self) -> usize
Returns the number of ADL alert items with stopped conditions.
Sourcepub fn total_balance(&self) -> f64
pub fn total_balance(&self) -> f64
Returns the total balance across all ADL alert items.
Sourcepub fn average_pnl_ratio(&self) -> Option<f64>
pub fn average_pnl_ratio(&self) -> Option<f64>
Returns the average PnL ratio across all ADL alert items.
Sourcepub fn min_balance(&self) -> Option<f64>
pub fn min_balance(&self) -> Option<f64>
Returns the minimum balance among all ADL alert items.
Sourcepub fn max_balance(&self) -> Option<f64>
pub fn max_balance(&self) -> Option<f64>
Returns the maximum balance among all ADL alert items.
Sourcepub fn most_at_risk_item(&self) -> Option<&ADLAlertWebsocketItem>
pub fn most_at_risk_item(&self) -> Option<&ADLAlertWebsocketItem>
Returns the item with the lowest balance (most at risk).
Sourcepub fn least_at_risk_item(&self) -> Option<&ADLAlertWebsocketItem>
pub fn least_at_risk_item(&self) -> Option<&ADLAlertWebsocketItem>
Returns the item with the highest balance (least at risk).
Sourcepub fn to_summary_string(&self) -> String
pub fn to_summary_string(&self) -> String
Returns a summary string for this ADL alert update.
Sourcepub fn is_valid_for_trading(&self) -> bool
pub fn is_valid_for_trading(&self) -> bool
Validates the update for trading use.
Returns true if:
- The update is not stale (≤ 2 seconds old)
- There is at least one ADL alert item
- The contract group can be extracted from the topic
Sourcepub fn latency_ms(&self, other_timestamp: u64) -> i64
pub fn latency_ms(&self, other_timestamp: u64) -> i64
Returns the update latency in milliseconds.
For comparing with other market data timestamps.
Sourcepub fn triggered_symbols(&self) -> Vec<String>
pub fn triggered_symbols(&self) -> Vec<String>
Returns all symbols that have ADL conditions triggered.
Sourcepub fn triggered_coins(&self) -> Vec<String>
pub fn triggered_coins(&self) -> Vec<String>
Returns all coins that have ADL conditions triggered.
Trait Implementations§
Source§impl Clone for ADLAlertUpdate
impl Clone for ADLAlertUpdate
Source§fn clone(&self) -> ADLAlertUpdate
fn clone(&self) -> ADLAlertUpdate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more