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
IcebergOrder
Iceberg order with visible and hidden quantities
Fields
The hidden quantity of the order
time_in_force: TimeInForceTime-in-force policy
extra_fields: TAdditional custom fields
PostOnly
Post-only order that won’t match immediately
TrailingStop
Trailing stop order that adjusts with market movement
PeggedOrder
Pegged order that adjusts based on reference price
Fields
time_in_force: TimeInForceTime-in-force policy
reference_price_type: PegReferenceTypeType of reference price to track
extra_fields: TAdditional custom fields
MarketToLimit
Market-to-limit order that converts to limit after initial execution
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
The hidden quantity of the order
time_in_force: TimeInForceTime-in-force policy
replenish_amount: Option<u64>Optional amount to replenish by. If None, uses DEFAULT_RESERVE_REPLENISH_AMOUNT
auto_replenish: boolWhether to replenish automatically when below threshold. If false, only replenish on next match
extra_fields: TAdditional custom fields
Implementations§
Source§impl<T: Clone> OrderType<T>
impl<T: Clone> OrderType<T>
Sourcepub fn visible_quantity(&self) -> u64
pub fn visible_quantity(&self) -> u64
Get the visible quantity
Get the hidden quantity
Sourcepub fn time_in_force(&self) -> TimeInForce
pub fn time_in_force(&self) -> TimeInForce
Get the time in force
Sourcepub fn is_immediate(&self) -> bool
pub fn is_immediate(&self) -> bool
Check if the order is immediate-or-cancel
Sourcepub fn is_fill_or_kill(&self) -> bool
pub fn is_fill_or_kill(&self) -> bool
Check if the order is fill-or-kill
Sourcepub fn is_post_only(&self) -> bool
pub fn is_post_only(&self) -> bool
Check if this is a post-only order
Sourcepub fn with_reduced_quantity(&self, new_quantity: u64) -> Self
pub fn with_reduced_quantity(&self, new_quantity: u64) -> Self
Create a new standard order with reduced quantity
Sourcepub fn refresh_iceberg(&self, refresh_amount: u64) -> (Self, u64)
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>
impl<T: Clone> OrderType<T>
Sourcepub fn match_against(
&self,
incoming_quantity: u64,
) -> (u64, Option<Self>, u64, u64)
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>
impl<T> OrderType<T>
Sourcepub fn extra_fields(&self) -> &T
pub fn extra_fields(&self) -> &T
Get the extra fields
Sourcepub fn extra_fields_mut(&mut self) -> &mut T
pub fn extra_fields_mut(&mut self) -> &mut T
Get mutable reference to extra fields
Sourcepub fn map_extra_fields<U, F>(self, f: F) -> OrderType<U>where
F: FnOnce(T) -> U,
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<'de, T> Deserialize<'de> for OrderType<T>where
T: Deserialize<'de>,
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>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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]
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