pub struct PriceLimitUpdate {
pub topic: String,
pub timestamp: u64,
pub data: PriceLimitData,
}Expand description
Represents a WebSocket price limit update event.
Contains real-time updates to order price limits for trading symbols. Push frequency: 300ms.
§Bybit API Reference
Topic: priceLimit.{symbol} (e.g., priceLimit.BTCUSDT)
Fields§
§topic: StringThe WebSocket topic for the event (e.g., “priceLimit.BTCUSDT”).
Specifies the data stream for the price limit update. Bots use this to determine which symbol the update belongs to.
timestamp: u64The timestamp of the event in milliseconds.
Indicates when the price limit update was generated by the system. Bots use this to ensure data freshness and time-based analysis.
data: PriceLimitDataThe price limit data.
Contains the current buy and sell price limits for the symbol.
Implementations§
Source§impl PriceLimitUpdate
impl PriceLimitUpdate
Sourcepub fn symbol_from_topic(&self) -> Option<&str>
pub fn symbol_from_topic(&self) -> Option<&str>
Extracts the symbol from the topic.
Parses the WebSocket topic to extract the trading symbol. Example: “priceLimit.BTCUSDT” -> “BTCUSDT”
Sourcepub fn is_consistent(&self) -> bool
pub fn is_consistent(&self) -> bool
Returns true if the symbol in the topic matches the symbol in the data.
Validates data consistency between the topic and the embedded data.
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 1 second).
Since price limit updates are pushed every 300ms, data older than 1 second might be considered stale for real-time trading decisions.
Sourcepub fn sell_limit(&self) -> f64
pub fn sell_limit(&self) -> f64
Returns the sell limit from the embedded data.
Sourcepub fn price_range(&self) -> f64
pub fn price_range(&self) -> f64
Returns the price range between buy and sell limits.
Sourcepub fn price_range_percentage(&self) -> f64
pub fn price_range_percentage(&self) -> f64
Returns the price range as a percentage of the mid price.
Sourcepub fn is_buy_price_allowed(&self, price: f64) -> bool
pub fn is_buy_price_allowed(&self, price: f64) -> bool
Checks if a buy price is within the allowed limit.
Sourcepub fn is_sell_price_allowed(&self, price: f64) -> bool
pub fn is_sell_price_allowed(&self, price: f64) -> bool
Checks if a sell price is within the allowed limit.
Sourcepub fn buy_slippage_limit(&self, reference_price: f64) -> f64
pub fn buy_slippage_limit(&self, reference_price: f64) -> f64
Returns the maximum allowable slippage for buy orders.
Sourcepub fn sell_slippage_limit(&self, reference_price: f64) -> f64
pub fn sell_slippage_limit(&self, reference_price: f64) -> f64
Returns the maximum allowable slippage for sell orders.
Sourcepub fn to_display_string(&self) -> String
pub fn to_display_string(&self) -> String
Returns a string representation of the 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 topic and data symbols are consistent
- The price limits are valid (positive values)
- The update is not stale (≤ 1 second old)
- The sell limit is greater than the buy limit (normal market)
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.
Trait Implementations§
Source§impl Clone for PriceLimitUpdate
impl Clone for PriceLimitUpdate
Source§fn clone(&self) -> PriceLimitUpdate
fn clone(&self) -> PriceLimitUpdate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more