Class MarketImpactModel
java.lang.Object
com.quantfinlib.microstructure.MarketImpactModel
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.
withCoefficients(double, double, double).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleadv()Average daily volume, in shares.doubleDaily return volatility (fraction).static MarketImpactModelEstimates a model for a trade decided at barindexfrom thewindowbars 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].doubleexpectedCostBps(double quantity, double participationRate) Expected implementation cost of executingquantityat the given participation rate: half the permanent impact (average price concession over the schedule) plus the full temporary impact.doublepermanentImpactBps(double quantity) Permanent (information) impact, linear in size relative to ADV.doublesquareRootImpactBps(double quantity) Square-root-law total impact for an order ofquantity.doubletemporaryImpactBps(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).
-
Constructor Details
-
MarketImpactModel
public MarketImpactModel(double adv, double dailyVolatility)
-
-
Method Details
-
withCoefficients
Returns a copy with calibrated coefficients (square-root Y, temporary eta bps, permanent gamma). -
estimate
Estimates a model for a trade decided at barindexfrom thewindowbars 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. Returnsnullwhen 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- whenindex <= 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 ofquantity. -
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 executingquantityat the given participation rate: half the permanent impact (average price concession over the schedule) plus the full temporary impact.
-