Skip to main content

FillModel

Trait FillModel 

Source
pub trait FillModel {
    // Required method
    fn fill_price(
        &self,
        side: Side,
        order_price: Option<Decimal>,
        best_bid: Option<Decimal>,
        best_ask: Option<Decimal>,
        last_price: Option<Decimal>,
    ) -> Option<Decimal>;
}
Expand description

Simulates the execution price for a backtest fill.

Called by the mock exchange engine when deciding at what price a pending order should be filled against incoming market data.

§Backtest-only

This trait is only relevant for simulated execution via MockExchange. Live execution clients receive real fill prices from the venue — they do not use FillModel.

§Arguments

  • side — order side (Buy or Sell).
  • order_price — limit price if limit order; None for market orders.
  • best_bid — current best bid in the order book, if available.
  • best_ask — current best ask in the order book, if available.
  • last_price — most recent trade price, if available.

Returns None if insufficient market data is available to determine a fill price (e.g. no prices at all on the first tick of a backtest).

Required Methods§

Source

fn fill_price( &self, side: Side, order_price: Option<Decimal>, best_bid: Option<Decimal>, best_ask: Option<Decimal>, last_price: Option<Decimal>, ) -> Option<Decimal>

Implementors§