pub struct MidpointFillModel;Expand description
Fills at the midpoint of best bid and best ask.
Falls back to order_price, then last_price when the book is incomplete.
Useful when modelling execution quality between taker (crossing spread) and maker (resting at the limit), or when bid/ask data is always available in the backtest feed.
§Note on order_price (limit orders)
Unlike BidAskFillModel, this model does not honour order_price
when both bid and ask are present — it always fills at the midpoint
regardless of the limit price. When the book is incomplete (only one
side present or neither), order_price is preferred over last_price
to avoid a fill at a worse price than the limit due to a stale last-trade
price (above the limit for buys, below the limit for sells).
The caller is responsible for invoking fill_price only when a limit
order is marketable (i.e., the limit has already been crossed). Using
MidpointFillModel for strategies that require limit-price guarantees
may result in fills at the midpoint rather than the limit.
Trait Implementations§
Source§impl Clone for MidpointFillModel
impl Clone for MidpointFillModel
Source§fn clone(&self) -> MidpointFillModel
fn clone(&self) -> MidpointFillModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MidpointFillModel
impl Debug for MidpointFillModel
Source§impl Default for MidpointFillModel
impl Default for MidpointFillModel
Source§fn default() -> MidpointFillModel
fn default() -> MidpointFillModel
Source§impl<'de> Deserialize<'de> for MidpointFillModel
impl<'de> Deserialize<'de> for MidpointFillModel
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 FillModel for MidpointFillModel
impl FillModel for MidpointFillModel
Source§impl Hash for MidpointFillModel
impl Hash for MidpointFillModel
Source§impl Ord for MidpointFillModel
impl Ord for MidpointFillModel
Source§fn cmp(&self, other: &MidpointFillModel) -> Ordering
fn cmp(&self, other: &MidpointFillModel) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for MidpointFillModel
impl PartialEq for MidpointFillModel
Source§fn eq(&self, other: &MidpointFillModel) -> bool
fn eq(&self, other: &MidpointFillModel) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for MidpointFillModel
impl PartialOrd for MidpointFillModel
Source§impl Serialize for MidpointFillModel
impl Serialize for MidpointFillModel
impl Copy for MidpointFillModel
impl Eq for MidpointFillModel
impl StructuralPartialEq for MidpointFillModel
Auto Trait Implementations§
impl Freeze for MidpointFillModel
impl RefUnwindSafe for MidpointFillModel
impl Send for MidpointFillModel
impl Sync for MidpointFillModel
impl Unpin for MidpointFillModel
impl UnsafeUnpin for MidpointFillModel
impl UnwindSafe for MidpointFillModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more