Skip to main content

RPIOrderbook

Struct RPIOrderbook 

Source
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: String

The 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: u64

The timestamp (ms) that the system generates the data.

§update_id: u64

Update ID, is always in sequence corresponds to u in the 50-level WebSocket RPI orderbook stream.

§sequence: u64

Cross 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: u64

The 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

Source

pub fn best_ask(&self) -> Option<f64>

Returns the best ask price (lowest ask).

Source

pub fn best_bid(&self) -> Option<f64>

Returns the best bid price (highest bid).

Source

pub fn best_ask_with_rpi(&self) -> Option<&RPIOrderbookLevel>

Returns the best ask with RPI information.

Source

pub fn best_bid_with_rpi(&self) -> Option<&RPIOrderbookLevel>

Returns the best bid with RPI information.

Source

pub fn spread(&self) -> Option<f64>

Returns the bid-ask spread.

Source

pub fn mid_price(&self) -> Option<f64>

Returns the mid price (average of best bid and ask).

Source

pub fn spread_percentage(&self) -> Option<f64>

Returns the spread as a percentage of mid price.

Source

pub fn total_ask_rpi_size(&self) -> f64

Returns the total RPI size on the ask side.

Source

pub fn total_ask_non_rpi_size(&self) -> f64

Returns the total non-RPI size on the ask side.

Source

pub fn total_bid_rpi_size(&self) -> f64

Returns the total RPI size on the bid side.

Source

pub fn total_bid_non_rpi_size(&self) -> f64

Returns the total non-RPI size on the bid side.

Source

pub fn total_ask_size(&self) -> f64

Returns the total size (RPI + non-RPI) on the ask side.

Source

pub fn total_bid_size(&self) -> f64

Returns the total size (RPI + non-RPI) on the bid side.

Source

pub fn total_ask_notional(&self) -> f64

Returns the total notional value on the ask side.

Source

pub fn total_bid_notional(&self) -> f64

Returns the total notional value on the bid side.

Source

pub fn average_ask_rpi_ratio(&self) -> f64

Returns the average RPI ratio on the ask side.

Source

pub fn average_bid_rpi_ratio(&self) -> f64

Returns the average RPI ratio on the bid side.

Source

pub fn rpi_ratio_imbalance(&self) -> f64

Returns the bid-ask RPI ratio difference.

Source

pub fn order_book_imbalance_with_rpi(&self) -> f64

Returns the order book imbalance considering RPI sizes.

Source

pub fn weighted_average_ask_price_with_rpi( &self, target_quantity: f64, ) -> Option<f64>

Returns the weighted average ask price considering RPI improvement.

Source

pub fn weighted_average_bid_price_with_rpi( &self, target_quantity: f64, ) -> Option<f64>

Returns the weighted average bid price considering RPI improvement.

Source

pub fn ask_price_impact_with_rpi(&self, quantity: f64) -> Option<f64>

Returns the price impact for a given quantity considering RPI.

Source

pub fn bid_price_impact_with_rpi(&self, quantity: f64) -> Option<f64>

Returns the price impact for a given quantity considering RPI.

Source

pub fn expected_taker_improvement( &self, is_buy: bool, quantity: f64, ) -> Option<f64>

Returns the expected price improvement for takers.

Source

pub fn liquidity_score_with_rpi(&self) -> f64

Returns the liquidity score considering RPI availability.

Source

pub fn timestamp_datetime(&self) -> DateTime<Utc>

Returns the timestamp as a DateTime.

Source

pub fn matching_engine_timestamp_datetime(&self) -> DateTime<Utc>

Returns the matching engine timestamp as a DateTime.

Source

pub fn processing_latency_ms(&self) -> i64

Returns the processing latency.

Trait Implementations§

Source§

impl Clone for RPIOrderbook

Source§

fn clone(&self) -> RPIOrderbook

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RPIOrderbook

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RPIOrderbook

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RPIOrderbook

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,