Class MarketImpactModel

java.lang.Object
com.quantfinlib.microstructure.MarketImpactModel

public final class MarketImpactModel extends Object
Temporary / permanent market impact models for large trades, parameterized by average daily volume (ADV) and daily volatility:
  • Square-root law (empirical standard): impact = Y * sigma_daily * sqrt(Q / ADV).
  • Almgren-Chriss style decomposition: linear temporary impact in participation rate and linear permanent impact in size, with the expected cost of an execution schedule E[cost] = permanent/2 + temporary.
All results in basis points of the arrival price. Coefficients default to commonly cited magnitudes; calibrate per market with withCoefficients(double, double, double).
  • Constructor Summary

    Constructors
    Constructor
    Description
    MarketImpactModel(double adv, double dailyVolatility)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    adv()
    Average daily volume, in shares.
    double
    Daily return volatility (fraction).
    estimate(BarSeries series, int index, int window)
    Estimates a model for a trade decided at bar index from the window bars strictly before it: ADV is the mean volume and daily volatility the population standard deviation of close-to-close returns over bars [index - window, index - 1].
    double
    expectedCostBps(double quantity, double participationRate)
    Expected implementation cost of executing quantity at the given participation rate: half the permanent impact (average price concession over the schedule) plus the full temporary impact.
    double
    permanentImpactBps(double quantity)
    Permanent (information) impact, linear in size relative to ADV.
    double
    squareRootImpactBps(double quantity)
    Square-root-law total impact for an order of quantity.
    double
    temporaryImpactBps(double participationRate)
    Temporary (execution-rate) impact at the given participation rate in [0, 1].
    withCoefficients(double y, double etaBps, double gamma)
    Returns a copy with calibrated coefficients (square-root Y, temporary eta bps, permanent gamma).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MarketImpactModel

      public MarketImpactModel(double adv, double dailyVolatility)
  • Method Details

    • withCoefficients

      public MarketImpactModel withCoefficients(double y, double etaBps, double gamma)
      Returns a copy with calibrated coefficients (square-root Y, temporary eta bps, permanent gamma).
    • estimate

      public static MarketImpactModel estimate(BarSeries series, int index, int window)
      Estimates a model for a trade decided at bar index from the window bars strictly before it: ADV is the mean volume and daily volatility the population standard deviation of close-to-close returns over bars [index - window, index - 1]. The trade bar's own volume and return are excluded because they are not known when the order is sized. This is the one bar-data to impact-model bridge, shared by the alpha and portfolio backtesters.

      Bars flagged synthetic (forward-filled alignment placeholders) are skipped in both estimates: a flat zero-volume bar would otherwise shrink ADV and volatility. A return ending on a real bar after a run of synthetic bars spans the gap; that is kept. Returns null when fewer than two real bars remain or the window has no volume (impact needs ADV; absent volume is a data gap, not free liquidity, so callers charge their flat costs and skip impact).

      Throws:
      IllegalArgumentException - when index <= window
    • adv

      public double adv()
      Average daily volume, in shares.
    • dailyVolatility

      public double dailyVolatility()
      Daily return volatility (fraction).
    • squareRootImpactBps

      public double squareRootImpactBps(double quantity)
      Square-root-law total impact for an order of quantity.
    • temporaryImpactBps

      public double temporaryImpactBps(double participationRate)
      Temporary (execution-rate) impact at the given participation rate in [0, 1].
    • permanentImpactBps

      public double permanentImpactBps(double quantity)
      Permanent (information) impact, linear in size relative to ADV.
    • expectedCostBps

      public double expectedCostBps(double quantity, double participationRate)
      Expected implementation cost of executing quantity at the given participation rate: half the permanent impact (average price concession over the schedule) plus the full temporary impact.