Skip to main content

matchcore/orders/
market.rs

1use crate::{Quantity, Side};
2
3/// Market order that is executed immediately and does not reside in the order book
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct MarketOrder {
7    /// The quantity of the order
8    quantity: Quantity,
9    /// The side of the order
10    side: Side,
11    /// Whether to convert the order to a limit order if it is not filled immediately
12    market_to_limit: bool,
13}
14
15impl MarketOrder {
16    /// Create a new market order
17    pub fn new(quantity: Quantity, side: Side, market_to_limit: bool) -> Self {
18        Self {
19            quantity,
20            side,
21            market_to_limit,
22        }
23    }
24
25    /// Get the quantity of the order
26    pub fn quantity(&self) -> Quantity {
27        self.quantity
28    }
29
30    /// Get the side of the order
31    pub fn side(&self) -> Side {
32        self.side
33    }
34
35    /// Get whether to convert the order to a limit order
36    pub fn market_to_limit(&self) -> bool {
37        self.market_to_limit
38    }
39}