Class IcebergExecution

java.lang.Object
com.quantfinlib.backtest.IcebergExecution
All Implemented Interfaces:
ExecutionModel

public final class IcebergExecution extends Object implements ExecutionModel
Iceberg execution: wraps another ExecutionModel and caps each bar's execution at the IcebergOrder state machine's visible tranche (optionally randomized), plus an optional participation cap versus the bar's volume. A fresh iceberg is loaded for every parent order, so entries and exits are both worked patiently across bars.
  • Constructor Details

    • IcebergExecution

      public IcebergExecution(ExecutionModel inner, long displayQty)
    • IcebergExecution

      public IcebergExecution(ExecutionModel inner, long displayQty, double randomizePct, double maxParticipation, long seed)
      Parameters:
      randomizePct - display-size jitter, e.g. 0.2 = ±20%
      maxParticipation - cap per bar as a fraction of bar volume (0 = off)
  • Method Details

    • worstCaseCostFraction

      public double worstCaseCostFraction()
      Description copied from interface: ExecutionModel
      Upper bound on this model's all-in cost as a fraction of ExecutionModel.referencePrice(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 than referencePrice * (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%.
      Specified by:
      worstCaseCostFraction in interface ExecutionModel
    • referencePrice

      public double referencePrice(BarSeries series, int index)
      Description copied from interface: ExecutionModel
      The price this model's fills are anchored to on the given bar — the engine budgets entry requests as cash / (referencePrice * (1 + worstCaseCostFraction())). Default: the bar close. A model that fills off a different price point (e.g. LastLookExecution fills at the OPEN) must override this, or a gap between close and its actual anchor lets a fully-filled request overdraw cash.
      Specified by:
      referencePrice in interface ExecutionModel
    • onParentOrder

      public void onParentOrder(Side side, long totalQuantity, int signalIndex)
      Description copied from interface: ExecutionModel
      Notification that a new parent order has been created (entry or exit). Stateful models (e.g. IcebergExecution) reset per-parent state here.
      Specified by:
      onParentOrder in interface ExecutionModel
    • execute

      public List<Execution> execute(Side side, long requestedQty, BarSeries series, int index)
      Description copied from interface: ExecutionModel
      Executes up to requestedQty on this bar. Must never fill more than requested; may fill less (or nothing) — the remainder is retried on subsequent bars.
      Specified by:
      execute in interface ExecutionModel