Interface TradeCostModel

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TradeCostModel
A pluggable per-trade cost model — the ONE definition of "what a trade costs" shared by the backtest engines, so an execution-aware number and a survivorship-aware number can come out of the same run:

The contract prices ONE side of a trade (a buy or a sell), all-in, in basis points of traded notional. Implementations must be pure functions of their arguments — engines may call them at any bar in any order.

  • Method Summary

    Modifier and Type
    Method
    Description
    double
    costBps(BarSeries series, int index, double notional)
    All-in one-way cost, in bps of traded notional, for trading notional (currency units, always positive) of series at bar index.
    flat(double bps)
    Fixed all-in bps per trade — commission-only, size-independent.
    institutional(double commissionBps, double halfSpreadBps, double slippageBps, int impactWindow)
    The institutional four-component model.
  • Method Details

    • costBps

      double costBps(BarSeries series, int index, double notional)
      All-in one-way cost, in bps of traded notional, for trading notional (currency units, always positive) of series at bar index.
    • flat

      static TradeCostModel flat(double bps)
      Fixed all-in bps per trade — commission-only, size-independent.
    • institutional

      static TradeCostModel institutional(double commissionBps, double halfSpreadBps, double slippageBps, int impactWindow)
      The institutional four-component model. Impact needs trailing ADV/vol: bars before impactWindow charge the flat components only (rather than reading before bar 0), as do series without volume data — documented degradation, never a crash.
      Parameters:
      commissionBps - commission per side
      halfSpreadBps - half the quoted spread, paid on every trade
      slippageBps - fixed implementation noise
      impactWindow - trailing bars for ADV/vol estimation (>= 2)