Skip to main content

OrderBookError

Enum OrderBookError 

Source
#[non_exhaustive]
pub enum OrderBookError {
Show 20 variants PriceLevelError(PriceLevelError), OrderNotFound(String), InvalidPriceLevel(u128), PriceCrossing { price: u128, side: Side, opposite_price: u128, }, InsufficientLiquidity { side: Side, requested: u64, available: u64, }, InsufficientLiquidityNotional { side: Side, requested: u128, spent: u128, }, InvalidOperation { message: String, }, KillSwitchActive, SerializationError { message: String, }, DeserializationError { message: String, }, ChecksumMismatch { expected: String, actual: String, }, InvalidTickSize { price: u128, tick_size: u128, }, InvalidLotSize { quantity: u64, lot_size: u64, }, OrderSizeOutOfRange { quantity: u64, min: Option<u64>, max: Option<u64>, }, DuplicateOrderId { order_id: Id, }, MissingUserId { order_id: Id, }, SelfTradePrevented { mode: STPMode, taker_order_id: Id, user_id: Hash32, }, RiskMaxOpenOrders { account: Hash32, current: u64, limit: u64, }, RiskMaxNotional { account: Hash32, current: u128, attempted: u128, limit: u128, }, RiskPriceBand { submitted: u128, reference: u128, deviation_bps: u32, limit_bps: u32, },
}
Expand description

Errors that can occur within the OrderBook

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

PriceLevelError(PriceLevelError)

Error from underlying price level operations

§

OrderNotFound(String)

Order not found in the book

§

InvalidPriceLevel(u128)

Invalid price level

§

PriceCrossing

Price crossing (bid >= ask)

Fields

§price: u128

Price that would cause crossing

§side: Side

Side of the order

§opposite_price: u128

Best opposite price

§

InsufficientLiquidity

Insufficient liquidity for market order

Fields

§side: Side

The side of the market order

§requested: u64

Quantity requested

§available: u64

Quantity available

§

InsufficientLiquidityNotional

Insufficient liquidity for a quote-notional market order. Returned by the *_by_amount paths when the book cannot fund a single whole lot against the requested notional. Distinct from OrderBookError::InsufficientLiquidity so callers can pattern-match on quote-vs-base semantics.

Fields

§side: Side

The side of the market order

§requested: u128

Notional (quote-asset value) requested

§spent: u128

Notional actually consumed before the walk gave up. Always 0 when this error is constructed (a non-zero spent returns Ok(MatchResult) with the partial fill instead).

§

InvalidOperation

Operation not permitted for specified order type

Fields

§message: String

Description of the error

§

KillSwitchActive

New flow (submit / modify / replace) is rejected because the kill switch is engaged. Cancel and mass-cancel paths still operate so operators can drain the book in an orderly way.

§

SerializationError

Error while serializing snapshot data

Fields

§message: String

Underlying error message

§

DeserializationError

Error while deserializing snapshot data

Fields

§message: String

Underlying error message

§

ChecksumMismatch

Snapshot integrity check failed

Fields

§expected: String

Expected checksum value

§actual: String

Actual checksum value

§

InvalidTickSize

Order price is not a multiple of the configured tick size

Fields

§price: u128

The order price that failed validation

§tick_size: u128

The configured tick size

§

InvalidLotSize

Order quantity is not a multiple of the configured lot size

Fields

§quantity: u64

The order quantity that failed validation

§lot_size: u64

The configured lot size

§

OrderSizeOutOfRange

Order quantity is outside the allowed min/max range

Fields

§quantity: u64

The order quantity that failed validation

§min: Option<u64>

The configured minimum order size, if any

§max: Option<u64>

The configured maximum order size, if any

§

DuplicateOrderId

Order rejected because its order_id duplicates an order that is already resting on the book. Admitting it would overwrite the existing order’s location and orphan it (the prior order could no longer be cancelled or modified by id), so the engine rejects the duplicate instead of silently replacing the live order. Maps to the stable wire code RejectReason::DuplicateOrderId.

This guards against sequential reuse of a live order’s id. It is not atomic against two concurrent submissions of the same fresh id on the lock-free admission path — serializing order ids is the ingress / sequencing layer’s responsibility.

Fields

§order_id: Id

The duplicate order ID that was rejected

§

MissingUserId

Order rejected because user_id is Hash32::zero() while Self-Trade Prevention is enabled. All orders must carry a non-zero user_id when STP mode is active.

Fields

§order_id: Id

The order ID that was rejected

§

SelfTradePrevented

Self-trade prevention triggered: the incoming order would have matched against a resting order from the same user.

Fields

§mode: STPMode

The STP mode that was active

§taker_order_id: Id

The taker (incoming) order ID

§user_id: Hash32

The user ID that triggered the STP check

§

RiskMaxOpenOrders

Per-account open-order limit breached.

Returned by limit-order admission when the requesting account already has current resting orders and the configured ceiling is limit. current >= limit always holds when this variant is constructed.

Fields

§account: Hash32

Account that breached the limit.

§current: u64

Account’s current resting-order count at check time.

§limit: u64

Configured maximum.

§

RiskMaxNotional

Per-account notional limit would be breached by this admission.

current + attempted > limit always holds when this variant is constructed. attempted is computed as submitted_quantity * submitted_price.

Fields

§account: Hash32

Account that breached the limit.

§current: u128

Account’s current resting notional at check time (raw ticks).

§attempted: u128

Notional this submission would add (raw ticks).

§limit: u128

Configured maximum (raw ticks).

§

RiskPriceBand

Submitted price exceeds the configured price band against the reference price.

deviation_bps > limit_bps always holds when this variant is constructed.

Fields

§submitted: u128

Limit price submitted by the caller (raw ticks).

§reference: u128

Resolved reference price at check time (raw ticks).

§deviation_bps: u32

Computed deviation in basis points. Saturates at u32::MAX.

§limit_bps: u32

Configured maximum allowed deviation in basis points.

Trait Implementations§

Source§

impl Clone for OrderBookError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for OrderBookError

Source§

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

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

impl Display for OrderBookError

Source§

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

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

impl Error for OrderBookError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<&OrderBookError> for RejectReason

Map a typed OrderBookError to its wire-side reject code.

Errors that do not represent a public reject (e.g. SerializationError, ChecksumMismatch, NatsPublishError, internal-state errors) map to [RejectReason::Other(0)] — they are not expected to surface on outbound reject events.

The match below is intentionally exhaustive (no _ => catch-all); any new variant added to OrderBookError must extend this mapping at compile time. This is enforced because the impl lives inside the crate, where exhaustive matches over a #[non_exhaustive] enum are still permitted.

Source§

fn from(err: &OrderBookError) -> Self

Converts to this type from the input type.
Source§

impl From<PriceLevelError> for OrderBookError

Source§

fn from(err: PriceLevelError) -> Self

Converts to this type from the input type.
Source§

impl From<SerializationError> for OrderBookError

Source§

fn from(err: SerializationError) -> Self

Folds a typed SerializationError into OrderBookError::SerializationError, preserving the underlying serde / bincode message via the error’s Display. Enables ?-propagation of an EventSerializer failure on paths returning OrderBookError.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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