Skip to main content

Fill

Struct Fill 

Source
pub struct Fill {
    pub quantity: Decimal,
    pub price: Decimal,
    pub taker_order_id: OrderId,
    pub maker_order_id: OrderId,
}
Expand description

Represents a match between two orders in the book.

A Fill is generated when two orders match and execute against each other. It contains all the information needed to track and report the trade.

§Fields

  • quantity - The size of this fill (may be partial)
  • price - The price at which the fill occurred
  • taker_order_id - The order that initiated the match (incoming order)
  • maker_order_id - The resting order that was matched against

§Terminology

  • Maker: The passive order already resting in the book
  • Taker: The aggressive order that crosses the spread and initiates the trade

§Example

let mut book = OrderBook::new(dec!(0.01)).unwrap();

// Add a resting sell order (maker)
let (maker_id, _) = book.add_limit_order(
    OrderSide::Sell,
    dec!(100.00),
    dec!(10),
).expect("invalid order");

// Add a buy order that crosses (taker)
let (taker_id, fills) = book.add_limit_order(
    OrderSide::Buy,
    dec!(100.00),
    dec!(5),
).expect("invalid order");

// Examine the fill
let fill = &fills[0];
assert_eq!(fill.quantity, dec!(5));
assert_eq!(fill.price, dec!(100.00));
assert_eq!(fill.maker_order_id, maker_id);
assert_eq!(fill.taker_order_id, taker_id);

Fields§

§quantity: Decimal§price: Decimal§taker_order_id: OrderId§maker_order_id: OrderId

Auto Trait Implementations§

§

impl Freeze for Fill

§

impl RefUnwindSafe for Fill

§

impl Send for Fill

§

impl Sync for Fill

§

impl Unpin for Fill

§

impl UnsafeUnpin for Fill

§

impl UnwindSafe for Fill

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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