Interface ExecutionModel
- All Known Implementing Classes:
IcebergExecution,InstantExecution,LastLookExecution,SorExecution
public interface ExecutionModel
How parent orders turn into fills in an execution-aware backtest
(
ExecutionAwareBacktester). The engine calls execute(com.quantfinlib.orderbook.Side, long, com.quantfinlib.core.BarSeries, int) once
per bar while a parent order is working; anything not filled carries over
to the next bar.
Returned fill prices are all-in (fees and spread folded in), so the engine's cash accounting is simply price × quantity.
-
Method Summary
Modifier and TypeMethodDescriptionExecutes up torequestedQtyon this bar.default voidonParentOrder(Side side, long totalQuantity, int signalIndex) Notification that a new parent order has been created (entry or exit).default doublereferencePrice(BarSeries series, int index) The price this model's fills are anchored to on the given bar — the engine budgets entry requests ascash / (referencePrice * (1 + worstCaseCostFraction())).default doubleUpper bound on this model's all-in cost as a fraction ofreferencePrice(com.quantfinlib.core.BarSeries, int)(spread + fees + slippage).
-
Method Details
-
onParentOrder
Notification that a new parent order has been created (entry or exit). Stateful models (e.g.IcebergExecution) reset per-parent state here. -
execute
-
referencePrice
The price this model's fills are anchored to on the given bar — the engine budgets entry requests ascash / (referencePrice * (1 + worstCaseCostFraction())). Default: the bar close. A model that fills off a different price point (e.g.LastLookExecutionfills at the OPEN) must override this, or a gap between close and its actual anchor lets a fully-filled request overdraw cash. -
worstCaseCostFraction
default double worstCaseCostFraction()Upper bound on this model's all-in cost as a fraction ofreferencePrice(com.quantfinlib.core.BarSeries, int)(spread + fees + slippage). The engine uses it to size entries so that a fully-filled parent can never overdraw cash — a model whose fills can cost more thanreferencePrice * (1 + worstCaseCostFraction())MUST override one or both methods, or the backtest silently trades on margin it doesn't have. Wrappers must DELEGATE both to the model that actually prices the fills. Default 1%.
-