pub struct RPIOrderbookUpdate {
pub topic: String,
pub event_type: String,
pub timestamp: u64,
pub data: RPIOrderbook,
pub cts: u64,
}Expand description
Structure for WebSocket RPI (Real-time Price Improvement) order book update events.
Contains real-time updates to the RPI order book for a trading pair, including bids, asks, RPI sizes, and sequence numbers. RPI orders can provide price improvement for takers. Bots use this for market depth analysis with RPI information and liquidity monitoring.
Fields§
§topic: StringThe WebSocket topic for the event (e.g., “orderbook.rpi.BTCUSDT”).
Specifies the data stream for the RPI order book update, including depth and symbol. Bots use this to verify the correct market and RPI depth level.
event_type: StringThe event type (e.g., “snapshot”, “delta”).
Indicates whether the update is a full snapshot or incremental delta. Bots use this to initialize or update their RPI order book state.
timestamp: u64The timestamp of the event in milliseconds.
Indicates when the RPI order book update was generated. Bots use this to ensure data freshness and align with other market data.
data: RPIOrderbookThe RPI order book data.
Contains the bids, asks with RPI information, and sequence numbers for the order book. Bots use this to update their internal RPI order book representation.
cts: u64The creation timestamp in milliseconds.
Indicates when the RPI order book update was created by Bybit’s matching engine. Bots use this to measure latency and ensure data consistency.
Implementations§
Source§impl RPIOrderbookUpdate
impl RPIOrderbookUpdate
Sourcepub fn symbol_from_topic(&self) -> Option<&str>
pub fn symbol_from_topic(&self) -> Option<&str>
Returns the symbol from the topic.
Extracts the trading pair symbol from the WebSocket topic. Example: “orderbook.rpi.BTCUSDT” -> “BTCUSDT”
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 order book state and should replace the local order book.
Sourcepub fn is_delta(&self) -> bool
pub fn is_delta(&self) -> bool
Returns true if this is a delta update.
Delta updates contain incremental changes and should be applied to the local order book.
Sourcepub fn processing_latency_ms(&self) -> i64
pub fn processing_latency_ms(&self) -> i64
Returns the processing latency in milliseconds.
Calculates the difference between the matching engine timestamp (cts) and the system generation timestamp (ts).
Sourcepub fn timestamp_datetime(&self) -> DateTime<Utc>
pub fn timestamp_datetime(&self) -> DateTime<Utc>
Returns the timestamp as a chrono DateTime.
Sourcepub fn creation_datetime(&self) -> DateTime<Utc>
pub fn creation_datetime(&self) -> DateTime<Utc>
Returns the creation timestamp as a chrono DateTime.
Sourcepub fn best_ask_with_rpi(&self) -> Option<&RPIOrderbookLevel>
pub fn best_ask_with_rpi(&self) -> Option<&RPIOrderbookLevel>
Returns the best ask with RPI information.
Sourcepub fn best_bid_with_rpi(&self) -> Option<&RPIOrderbookLevel>
pub fn best_bid_with_rpi(&self) -> Option<&RPIOrderbookLevel>
Returns the best bid with RPI information.
Sourcepub fn spread_percentage(&self) -> Option<f64>
pub fn spread_percentage(&self) -> Option<f64>
Returns the spread as a percentage of mid price.
Sourcepub fn total_ask_rpi_size(&self) -> f64
pub fn total_ask_rpi_size(&self) -> f64
Returns the total RPI size on the ask side.
Sourcepub fn total_ask_non_rpi_size(&self) -> f64
pub fn total_ask_non_rpi_size(&self) -> f64
Returns the total non-RPI size on the ask side.
Sourcepub fn total_bid_rpi_size(&self) -> f64
pub fn total_bid_rpi_size(&self) -> f64
Returns the total RPI size on the bid side.
Sourcepub fn total_bid_non_rpi_size(&self) -> f64
pub fn total_bid_non_rpi_size(&self) -> f64
Returns the total non-RPI size on the bid side.
Sourcepub fn average_ask_rpi_ratio(&self) -> f64
pub fn average_ask_rpi_ratio(&self) -> f64
Returns the average RPI ratio on the ask side.
Sourcepub fn average_bid_rpi_ratio(&self) -> f64
pub fn average_bid_rpi_ratio(&self) -> f64
Returns the average RPI ratio on the bid side.
Sourcepub fn rpi_ratio_imbalance(&self) -> f64
pub fn rpi_ratio_imbalance(&self) -> f64
Returns the bid-ask RPI ratio difference.
Sourcepub fn order_book_imbalance_with_rpi(&self) -> f64
pub fn order_book_imbalance_with_rpi(&self) -> f64
Returns the order book imbalance considering RPI sizes.
Sourcepub fn liquidity_score_with_rpi(&self) -> f64
pub fn liquidity_score_with_rpi(&self) -> f64
Returns the liquidity score considering RPI availability.
Sourcepub fn expected_taker_improvement(
&self,
is_buy: bool,
quantity: f64,
) -> Option<f64>
pub fn expected_taker_improvement( &self, is_buy: bool, quantity: f64, ) -> Option<f64>
Returns the expected price improvement for takers.
Sourcepub fn ask_price_impact_with_rpi(&self, quantity: f64) -> Option<f64>
pub fn ask_price_impact_with_rpi(&self, quantity: f64) -> Option<f64>
Returns the price impact for a given quantity considering RPI.
Sourcepub fn bid_price_impact_with_rpi(&self, quantity: f64) -> Option<f64>
pub fn bid_price_impact_with_rpi(&self, quantity: f64) -> Option<f64>
Returns the price impact for a given quantity considering RPI.
Sourcepub fn weighted_average_ask_price_with_rpi(
&self,
target_quantity: f64,
) -> Option<f64>
pub fn weighted_average_ask_price_with_rpi( &self, target_quantity: f64, ) -> Option<f64>
Returns the weighted average ask price considering RPI improvement.
Sourcepub fn weighted_average_bid_price_with_rpi(
&self,
target_quantity: f64,
) -> Option<f64>
pub fn weighted_average_bid_price_with_rpi( &self, target_quantity: f64, ) -> Option<f64>
Returns the weighted average bid price considering RPI improvement.
Trait Implementations§
Source§impl Clone for RPIOrderbookUpdate
impl Clone for RPIOrderbookUpdate
Source§fn clone(&self) -> RPIOrderbookUpdate
fn clone(&self) -> RPIOrderbookUpdate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more