Skip to main content

FillModel

Enum FillModel 

Source
pub enum FillModel {
    TakerAtClose,
    Resting,
}
Expand description

How the replay engine turns orders into fills.

Selected via BacktestConfig::fill_model (builder: .fill_model(FillModel::…)). Defaults to FillModel::TakerAtClose, the engine’s historical behaviour — existing backtests are bit-identical with the default.

Variants§

§

TakerAtClose

Legacy single-candle fills (the default).

Market / IOC / FOK entries and closes fill as takers at the decision candle’s close. Limit / post-only entries fill only if the decision candle itself crosses the level (marketability judged against the candle open; a marketable limit fills at the open as taker, a marketable post-only is rejected) and are dropped otherwise — nothing rests across candles. Protective brackets require both SL and TP legs and fill at their fixed level even when a candle gaps through it.

§

Resting

Honest resting-order semantics.

Orders reach the synthetic book at the decision candle’s close (the market price at decision time), so the decision candle can never fill a resting order — its range printed before the order existed (no lookahead).

  • Market entries and closes fill at the decision close as takers, same as legacy.
  • Limit / post-only entries marketable at the close fill immediately at the close as takers (a marketable post-only is rejected). Non-marketable ones rest (GTC) and fill on the first later candle that crosses the level: at the limit price on a cross, or at that candle’s open when the candle gaps through the level — never at a better price than the market offered. Resting fills are makers: maker fee rate, no slippage.
  • IOC / FOK entries that are not marketable at the close are cancelled (the engine has no book depth, so both fill in full or not at all).
  • Protective stops trigger on a cross and fill at the stop level or worse (gap through → that candle’s open), as takers with slippage. Take-profits are resting limits: level on a cross, open on a gap (price improvement), maker fee, no slippage. Standalone (stop-only or TP-only) brackets are honoured — legacy mode requires both legs.
  • Same-candle ambiguity (multiple levels inside one candle’s range, OHLC path unknown) resolves to the worse outcome for the strategy: the stop leg fires before the take-profit leg; on the candle a resting entry fills, its attached stop may fire on that same candle, but its take-profit only becomes eligible from the next candle.
  • At most one resting entry per symbol: any later non-Hold decision that passes the risk gates cancels it (cancel-and-replace, where the replacement may be nothing).

Trait Implementations§

Source§

impl Clone for FillModel

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FillModel

Source§

impl Debug for FillModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FillModel

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FillModel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for FillModel

Source§

impl PartialEq for FillModel

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for FillModel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for FillModel

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more