Class LiquidityMeasures
java.lang.Object
com.quantfinlib.microstructure.LiquidityMeasures
Liquidity estimated from BARS ALONE — the estimators for every
market where you have prices but no quotes: history before your tick
capture started, less-developed markets, bonds marked once a day, or
a 20-year backtest that would otherwise pretend spreads were zero.
- Roll (1984) — the effective spread implied by bid-ask
BOUNCE: trade prices ping-ponging between bid and ask create
negative autocovariance in price changes, and
s = 2√(−cov(Δp_t, Δp_{t−1})). When the autocovariance is POSITIVE (trending sample, no bounce signature) the estimator is undefined and returns NaN — not zero, because "zero spread" is a claim and NaN is an honest shrug; - Corwin-Schultz (2012) — the spread from two days' HIGH-LOW ranges: variance grows with time but the spread does not, so comparing one 2-day range against two 1-day ranges isolates the spread. Negative estimates clamp to 0 (standard practice, stated);
- Amihud (2002) — price impact per currency unit traded:
mean(|return| / dollarVolume). The cross-sectional illiquidity ranker — multiply by 1e6 for the conventional "per million" quotation.
Static, deterministic, research lane. These are ESTIMATORS with real sampling error on short windows — rank with them, do not mark books with them.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleamihudIlliquidity(double[] returns, double[] dollarVolumes) Amihud illiquidity:mean(|return| / dollarVolume)— return per currency unit traded.static doublecorwinSchultzSpread(double high1, double low1, double high2, double low2) Corwin-Schultz high-low spread estimate as a FRACTION of price, from two consecutive periods' highs and lows.static doublerollSpread(double[] prices) Roll's implied effective spread from trade/close prices (same units as the prices).
-
Method Details
-
rollSpread
public static double rollSpread(double[] prices) Roll's implied effective spread from trade/close prices (same units as the prices). NaN when the bounce signature is absent — see class doc.- Parameters:
prices- ≥ 3 finite positive prices
-
corwinSchultzSpread
public static double corwinSchultzSpread(double high1, double low1, double high2, double low2) Corwin-Schultz high-low spread estimate as a FRACTION of price, from two consecutive periods' highs and lows. Negative estimates clamp to 0 (stated standard practice). -
amihudIlliquidity
public static double amihudIlliquidity(double[] returns, double[] dollarVolumes) Amihud illiquidity:mean(|return| / dollarVolume)— return per currency unit traded. Zero-volume periods are a data problem, not an infinity: they throw.- Parameters:
returns- per-period returns (fractions), finitedollarVolumes- per-period traded value, > 0, aligned
-