Skip to main content

PriceLimitData

Struct PriceLimitData 

Source
pub struct PriceLimitData {
    pub symbol: String,
    pub buy_lmt: f64,
    pub sell_lmt: f64,
}
Expand description

Represents the order price limits for a single trading symbol in a WebSocket update.

Contains the highest bid price (buyLmt) and lowest ask price (sellLmt) for a given symbol. These limits define the order price boundaries for derivative or spot trading and are important for risk management and order validation.

§Bybit API Reference

The Bybit WebSocket API (https://bybit-exchange.github.io/docs/v5/websocket/public/order-price-limit) provides real-time order price limit updates with a push frequency of 300ms.

Fields§

§symbol: String

The trading pair symbol (e.g., “BTCUSDT”).

Identifies the specific instrument for which the price limits apply. Trading bots should verify this matches the requested symbol to ensure data integrity.

§buy_lmt: f64

The highest bid price allowed (buy limit) as a string.

Represents the maximum price at which buy orders can be placed. Orders with prices above this limit will be rejected. Trading bots must ensure buy order prices do not exceed this limit.

§sell_lmt: f64

The lowest ask price allowed (sell limit) as a string.

Represents the minimum price at which sell orders can be placed. Orders with prices below this limit will be rejected. Trading bots must ensure sell order prices are not below this limit.

Implementations§

Source§

impl PriceLimitData

Source

pub fn new(symbol: &str, buy_lmt: f64, sell_lmt: f64) -> Self

Constructs a new PriceLimitData with specified parameters.

Source

pub fn is_buy_limit_valid(&self) -> bool

Returns true if the buy limit is valid (positive value).

Source

pub fn is_sell_limit_valid(&self) -> bool

Returns true if the sell limit is valid (positive value).

Source

pub fn is_valid(&self) -> bool

Returns true if both price limits are valid.

Source

pub fn price_range(&self) -> f64

Returns the price range between buy and sell limits.

Calculated as sell_lmt - buy_lmt. A positive value indicates normal market conditions where sell limit is higher than buy limit. A negative value would indicate abnormal market conditions.

Source

pub fn mid_price(&self) -> f64

Returns the mid price between buy and sell limits.

Calculated as (buy_lmt + sell_lmt) / 2.0. This represents the theoretical fair value within the allowed trading range.

Source

pub fn price_range_percentage(&self) -> f64

Returns the price range as a percentage of the mid price.

Useful for understanding the relative width of the allowed trading range. Calculated as price_range() / mid_price() * 100.0.

Source

pub fn is_buy_price_allowed(&self, price: f64) -> bool

Checks if a buy price is within the allowed limit.

Returns true if price <= buy_lmt, meaning the buy order price is acceptable.

Source

pub fn is_sell_price_allowed(&self, price: f64) -> bool

Checks if a sell price is within the allowed limit.

Returns true if price >= sell_lmt, meaning the sell order price is acceptable.

Source

pub fn buy_slippage_limit(&self, reference_price: f64) -> f64

Returns the maximum allowable slippage for buy orders.

Calculated as (buy_lmt - reference_price) / reference_price where reference_price is typically the current market price or the price a bot intends to use.

Source

pub fn sell_slippage_limit(&self, reference_price: f64) -> f64

Returns the maximum allowable slippage for sell orders.

Calculated as (reference_price - sell_lmt) / reference_price where reference_price is typically the current market price or the price a bot intends to use.

Source

pub fn limits(&self) -> (f64, f64)

Returns the price limits as a tuple (buy_limit, sell_limit).

Source

pub fn to_display_string(&self) -> String

Returns a string representation of the price limits.

Source

pub fn expiry_timestamp(&self) -> Option<DateTime<Utc>>

Returns the timestamp from the symbol, if it contains expiry information.

For futures contracts with expiry dates in the symbol (e.g., “BTC-26DEC25”), this attempts to extract and parse the expiry date.

Source

pub fn is_perpetual(&self) -> bool

Returns true if this is a perpetual contract (no expiry).

Source

pub fn is_futures(&self) -> bool

Returns true if this is a futures contract (has expiry).

Trait Implementations§

Source§

impl Clone for PriceLimitData

Source§

fn clone(&self) -> PriceLimitData

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 PriceLimitData

Source§

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

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

impl<'de> Deserialize<'de> for PriceLimitData

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 PriceLimitData

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>,