Class ExecutionAwareBacktester

java.lang.Object
com.quantfinlib.backtest.ExecutionAwareBacktester

public final class ExecutionAwareBacktester extends Object
Execution-aware backtesting engine: strategy signals create parent orders that are worked through an ExecutionModel — routed by SorExecution, sliced by IcebergExecution, or filled instantly by InstantExecution. Fills can span multiple bars, the position accumulates gradually, and every child fill is recorded so execution cost (TCA) is measurable per parent order.

Semantics (long-only, single instrument, like Backtester):

  • BUY signal while flat → entry parent sized to available cash; worked from the signal bar until filled or superseded.
  • SELL signal → cancels any unfilled entry remainder and works an exit parent for the whole position.
  • Stop-loss / take-profit are evaluated intrabar against the volume-weighted average entry price; the triggered exit is worked through the execution model (a patient model exits slowly — that realism is the point).
  • Any position left at the end of data is force-closed at the last close less the model's worst-case cost fraction — unconditional (it bypasses the model's fill logic) but not free.