pub struct RPIOrderbook {
pub symbol: String,
pub asks: Vec<RPIOrderbookLevel>,
pub bids: Vec<RPIOrderbookLevel>,
pub timestamp: u64,
pub update_id: u64,
pub sequence: u64,
pub matching_engine_timestamp: u64,
}Expand description
Represents the RPI (Real-time Price Improvement) order book for a trading pair.
Contains the current bid and ask levels with RPI information, along with metadata. RPI order books show both regular orders and RPI orders, which can provide price improvement.
Fields§
§symbol: StringThe trading pair symbol (e.g., “BTCUSDT”).
asks: Vec<RPIOrderbookLevel>A list of ask (sell) orders with RPI information.
Each element is an array of [price, non-RPI size, RPI size]. Sorted by price in ascending order.
bids: Vec<RPIOrderbookLevel>A list of bid (buy) orders with RPI information.
Each element is an array of [price, non-RPI size, RPI size]. Sorted by price in descending order.
timestamp: u64The timestamp (ms) that the system generates the data.
update_id: u64Update ID, is always in sequence corresponds to u in the 50-level WebSocket RPI orderbook stream.
sequence: u64Cross sequence.
You can use this field to compare different levels orderbook data, and for the smaller seq, then it means the data is generated earlier.
matching_engine_timestamp: u64The timestamp from the matching engine when this orderbook data is produced.
It can be correlated with T from public trade channel.
Implementations§
Source§impl RPIOrderbook
impl RPIOrderbook
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 total_ask_size(&self) -> f64
pub fn total_ask_size(&self) -> f64
Returns the total size (RPI + non-RPI) on the ask side.
Sourcepub fn total_bid_size(&self) -> f64
pub fn total_bid_size(&self) -> f64
Returns the total size (RPI + non-RPI) on the bid side.
Sourcepub fn total_ask_notional(&self) -> f64
pub fn total_ask_notional(&self) -> f64
Returns the total notional value on the ask side.
Sourcepub fn total_bid_notional(&self) -> f64
pub fn total_bid_notional(&self) -> f64
Returns the total notional value 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 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.
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 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 liquidity_score_with_rpi(&self) -> f64
pub fn liquidity_score_with_rpi(&self) -> f64
Returns the liquidity score considering RPI availability.
Sourcepub fn timestamp_datetime(&self) -> DateTime<Utc>
pub fn timestamp_datetime(&self) -> DateTime<Utc>
Returns the timestamp as a DateTime.
Sourcepub fn matching_engine_timestamp_datetime(&self) -> DateTime<Utc>
pub fn matching_engine_timestamp_datetime(&self) -> DateTime<Utc>
Returns the matching engine timestamp as a DateTime.
Sourcepub fn processing_latency_ms(&self) -> i64
pub fn processing_latency_ms(&self) -> i64
Returns the processing latency.
Trait Implementations§
Source§impl Clone for RPIOrderbook
impl Clone for RPIOrderbook
Source§fn clone(&self) -> RPIOrderbook
fn clone(&self) -> RPIOrderbook
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more