OrderType

Enum OrderType 

Source
pub enum OrderType<T> {
    Standard {
        id: OrderId,
        price: u64,
        quantity: u64,
        side: Side,
        timestamp: u64,
        time_in_force: TimeInForce,
        extra_fields: T,
    },
    IcebergOrder {
        id: OrderId,
        price: u64,
        visible_quantity: u64,
        hidden_quantity: u64,
        side: Side,
        timestamp: u64,
        time_in_force: TimeInForce,
        extra_fields: T,
    },
    PostOnly {
        id: OrderId,
        price: u64,
        quantity: u64,
        side: Side,
        timestamp: u64,
        time_in_force: TimeInForce,
        extra_fields: T,
    },
    TrailingStop {
        id: OrderId,
        price: u64,
        quantity: u64,
        side: Side,
        timestamp: u64,
        time_in_force: TimeInForce,
        trail_amount: u64,
        last_reference_price: u64,
        extra_fields: T,
    },
    PeggedOrder {
        id: OrderId,
        price: u64,
        quantity: u64,
        side: Side,
        timestamp: u64,
        time_in_force: TimeInForce,
        reference_price_offset: i64,
        reference_price_type: PegReferenceType,
        extra_fields: T,
    },
    MarketToLimit {
        id: OrderId,
        price: u64,
        quantity: u64,
        side: Side,
        timestamp: u64,
        time_in_force: TimeInForce,
        extra_fields: T,
    },
    ReserveOrder {
        id: OrderId,
        price: u64,
        visible_quantity: u64,
        hidden_quantity: u64,
        side: Side,
        timestamp: u64,
        time_in_force: TimeInForce,
        replenish_threshold: u64,
        replenish_amount: Option<u64>,
        auto_replenish: bool,
        extra_fields: T,
    },
}
Expand description

Represents different types of limit orders

Variants§

§

Standard

Standard limit order

Fields

§id: OrderId

The order ID

§price: u64

The price of the order

§quantity: u64

The quantity of the order

§side: Side

The side of the order (buy or sell)

§timestamp: u64

When the order was created

§time_in_force: TimeInForce

Time-in-force policy

§extra_fields: T

Additional custom fields

§

IcebergOrder

Iceberg order with visible and hidden quantities

Fields

§id: OrderId

The order ID

§price: u64

The price of the order

§visible_quantity: u64

The visible quantity of the order

§hidden_quantity: u64

The hidden quantity of the order

§side: Side

The side of the order (buy or sell)

§timestamp: u64

When the order was created

§time_in_force: TimeInForce

Time-in-force policy

§extra_fields: T

Additional custom fields

§

PostOnly

Post-only order that won’t match immediately

Fields

§id: OrderId

The order ID

§price: u64

The price of the order

§quantity: u64

The quantity of the order

§side: Side

The side of the order (buy or sell)

§timestamp: u64

When the order was created

§time_in_force: TimeInForce

Time-in-force policy

§extra_fields: T

Additional custom fields

§

TrailingStop

Trailing stop order that adjusts with market movement

Fields

§id: OrderId

The order ID

§price: u64

The price of the order

§quantity: u64

The quantity of the order

§side: Side

The side of the order (buy or sell)

§timestamp: u64

When the order was created

§time_in_force: TimeInForce

Time-in-force policy

§trail_amount: u64

Amount to trail the market price

§last_reference_price: u64

Last reference price

§extra_fields: T

Additional custom fields

§

PeggedOrder

Pegged order that adjusts based on reference price

Fields

§id: OrderId

The order ID

§price: u64

The price of the order

§quantity: u64

The quantity of the order

§side: Side

The side of the order (buy or sell)

§timestamp: u64

When the order was created

§time_in_force: TimeInForce

Time-in-force policy

§reference_price_offset: i64

Offset from the reference price

§reference_price_type: PegReferenceType

Type of reference price to track

§extra_fields: T

Additional custom fields

§

MarketToLimit

Market-to-limit order that converts to limit after initial execution

Fields

§id: OrderId

The order ID

§price: u64

The price of the order

§quantity: u64

The quantity of the order

§side: Side

The side of the order (buy or sell)

§timestamp: u64

When the order was created

§time_in_force: TimeInForce

Time-in-force policy

§extra_fields: T

Additional custom fields

§

ReserveOrder

Reserve order with custom replenishment if replenish_amount is None, it uses DEFAULT_RESERVE_REPLENISH_AMOUNT if auto_replenish is false, and visible quantity is below threshold, it will not replenish if auto_replenish is false and visible quantity is zero it will be removed from the book if auto_replenish is true, and replenish_threshold is 0, it will use 1

Fields

§id: OrderId

The order ID

§price: u64

The price of the order

§visible_quantity: u64

The visible quantity of the order

§hidden_quantity: u64

The hidden quantity of the order

§side: Side

The side of the order (buy or sell)

§timestamp: u64

When the order was created

§time_in_force: TimeInForce

Time-in-force policy

§replenish_threshold: u64

Threshold at which to replenish

§replenish_amount: Option<u64>

Optional amount to replenish by. If None, uses DEFAULT_RESERVE_REPLENISH_AMOUNT

§auto_replenish: bool

Whether to replenish automatically when below threshold. If false, only replenish on next match

§extra_fields: T

Additional custom fields

Implementations§

Source§

impl<T: Clone> OrderType<T>

Source

pub fn id(&self) -> OrderId

Get the order ID

Source

pub fn price(&self) -> u64

Get the price

Source

pub fn visible_quantity(&self) -> u64

Get the visible quantity

Source

pub fn hidden_quantity(&self) -> u64

Get the hidden quantity

Source

pub fn side(&self) -> Side

Get the order side

Source

pub fn time_in_force(&self) -> TimeInForce

Get the time in force

Source

pub fn timestamp(&self) -> u64

Get the timestamp

Source

pub fn is_immediate(&self) -> bool

Check if the order is immediate-or-cancel

Source

pub fn is_fill_or_kill(&self) -> bool

Check if the order is fill-or-kill

Source

pub fn is_post_only(&self) -> bool

Check if this is a post-only order

Source

pub fn with_reduced_quantity(&self, new_quantity: u64) -> Self

Create a new standard order with reduced quantity

Source

pub fn refresh_iceberg(&self, refresh_amount: u64) -> (Self, u64)

Update an iceberg order, refreshing visible part from hidden

Source§

impl<T: Clone> OrderType<T>

Source

pub fn match_against( &self, incoming_quantity: u64, ) -> (u64, Option<Self>, u64, u64)

Matches this order against an incoming quantity

Returns a tuple containing:

  • The quantity consumed from the incoming order
  • Optionally, an updated version of this order (if partially filled)
  • The quantity that was reduced from hidden portion (for iceberg/reserve orders)
  • The remaining quantity of the incoming order
Source§

impl<T> OrderType<T>

Source

pub fn extra_fields(&self) -> &T

Get the extra fields

Source

pub fn extra_fields_mut(&mut self) -> &mut T

Get mutable reference to extra fields

Source

pub fn map_extra_fields<U, F>(self, f: F) -> OrderType<U>
where F: FnOnce(T) -> U,

Transform the extra fields type using a function

Trait Implementations§

Source§

impl<T: Clone> Clone for OrderType<T>

Source§

fn clone(&self) -> OrderType<T>

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<T: Debug> Debug for OrderType<T>

Source§

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

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

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

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<T> Display for OrderType<T>

Source§

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

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

impl<T: Default> FromStr for OrderType<T>

Expected string format: ORDER_TYPE:id=<id>;price=<price>;quantity=<qty>;side=<BUY|SELL>;timestamp=<ts>;time_in_force=<tif>;[additional fields]

Examples:

  • Standard:id=123;price=10000;quantity=5;side=BUY;timestamp=1616823000000;time_in_force=GTC
  • IcebergOrder:id=124;price=10000;visible_quantity=1;hidden_quantity=4;side=SELL;timestamp=1616823000000;time_in_force=GTC
Source§

type Err = PriceLevelError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<T: PartialEq> PartialEq for OrderType<T>

Source§

fn eq(&self, other: &OrderType<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for OrderType<T>
where T: Serialize,

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
Source§

impl<T: Copy> Copy for OrderType<T>

Source§

impl<T: Eq> Eq for OrderType<T>

Source§

impl<T> StructuralPartialEq for OrderType<T>

Auto Trait Implementations§

§

impl<T> Freeze for OrderType<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for OrderType<T>
where T: RefUnwindSafe,

§

impl<T> Send for OrderType<T>
where T: Send,

§

impl<T> Sync for OrderType<T>
where T: Sync,

§

impl<T> Unpin for OrderType<T>
where T: Unpin,

§

impl<T> UnwindSafe for OrderType<T>
where T: UnwindSafe,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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
Source§

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