Class SlippageExecutorBase<TState, TAction, TEvent>
Executor base that models bid-ask slippage. Subclasses define the slippage distribution (no distribution assumed by the base) and how the slippage value is applied to the case-by-case fill logic.
public abstract class SlippageExecutorBase<TState, TAction, TEvent> : IExecutor<TState, TAction, TEvent> where TState : IExecutionState where TAction : ITradeAction where TEvent : ITradeEvent<TAction, DateTimeOffset>
Type Parameters
TStateTActionTEvent
- Inheritance
-
SlippageExecutorBase<TState, TAction, TEvent>
- Implements
-
IExecutor<TState, TAction, TEvent>
- Inherited Members
Remarks
Template method pattern. The base owns the Execute flow: it calls CalculateSlippage(TState, TAction) to obtain a (next-state, slippage) pair, then passes both to Process(TState, TAction, double). Subclasses define both hooks — the slippage distribution (Gaussian, uniform, log-normal, constant, etc.) and the case-by-case fill logic that consumes the slippage value.
Properties
Initial
The initial state of the executor.
public abstract TState Initial { get; }
Property Value
- TState
Methods
CalculateSlippage(TState, TAction)
Subclass hook: advance state (e.g. step a PRNG) and return the slippage value for this action. The base imposes no distribution — subclasses choose.
protected abstract (TState NextState, double Slippage) CalculateSlippage(TState state, TAction action)
Parameters
stateTStateCurrent executor state.
actionTActionThe trade action whose slippage is being computed.
Returns
- (TState NextState, double Slippage)
Tuple of (next state, slippage). The slippage value's unit and interpretation are subclass-defined (e.g. basis points, fraction, absolute offset).
Remarks
The returned state is forwarded to Process(TState, TAction, double); the slippage is also passed in. This means a subclass can advance the PRNG (or similar state evolution) here without re-implementing the Execute flow.
ExecuteAsync(TState, TAction)
Execute one TAction, producing the next state and an outcome event.
public Task<(TState NextState, TEvent Event)> ExecuteAsync(TState state, TAction action)
Parameters
stateTStateCurrent executor state.
actionTActionThe action to execute.
Returns
Process(TState, TAction, double)
Subclass hook: given the (state after CalculateSlippage(TState, TAction)), the action, and the slippage value, produce the next state and the outcome event.
protected abstract (TState NextState, TEvent Event) Process(TState state, TAction action, double slippage)
Parameters
stateTStateThe state returned by CalculateSlippage(TState, TAction).
actionTActionThe trade action to process.
slippagedoubleThe slippage value from CalculateSlippage(TState, TAction).
Returns
Remarks
Implementations typically apply the slippage to fill actions (buy/sell)
and emit the appropriate TEvent subtype. The
base imposes no assumption about how the slippage is applied — the
subclass owns the formula.