Function returns an xts or data.table object containing 23 liquidity measures. Please see details below.
Note that this assumes a regular time grid. The Lee + Ready measure uses two lags for the Tick Rule.
Compute Liquidity Measure
Function returns an xts or data.table object containing 23 liquidity measures. Please see details below.
Note that this assumes a regular time grid. The Lee + Ready measure uses two lags for the Tick Rule.
getLiquidityMeasures(tqData, win = 300, type = NULL)
A data.table
or xts object as in the highfrequency merged
trades and quotes data (that is included).
A windows length for the forward-prices used for ‘realized’ spread
Legacy option. Default is to return all liquidity measures.
A modified (enlarged) xts
or data.table
with the new measures.
NOTE: xts or data.table should only contain one day of observations
The respective liquidity measures are defined as follows:
effectiveSpread $$ \mbox{effective spread}_t = 2*D_t*(\mbox{PRICE}_{t} - \frac{(\mbox{BID}_{t}+\mbox{OFR}_{t})}{2}), $$ where \(D_t\) is 1 (-1) if \(trade_t\) was buy (sell) (see Boehmer (2005), Bessembinder (2003)). Note that the input of this function consists of the matched trades and quotes, so this is were the time indication refers to (and thus not to the registered quote timestamp).
realizedSpread: realized spread $$ \mbox{realized spread}_t = 2*D_t*(\mbox{PRICE}_{t} - \frac{(\mbox{BID}_{t+300}+\mbox{OFR}_{t+300})}{2}), $$
where \(D_t\) is 1 (-1) if \(trade_t\) was buy (sell) (see Boehmer (2005), Bessembinder (2003)). Note that the time indication of \(\mbox{BID}\) and \(\mbox{OFR}\) refers to the registered time of the quote in seconds.
valueTrade: trade value $$ \mbox{trade value}_t = \mbox{SIZE}_{t}*\mbox{PRICE}_{t}. $$
signedValueTrad: signed trade value $$ \mbox{signed trade value}_t = D_t * (\mbox{SIZE}_{t}*\mbox{PRICE}_{t}),$$ where \(D_t\) is 1 (-1) if \(trade_t\) was buy (sell) (see Boehmer (2005), Bessembinder (2003)).
depthImbalanceDifference: depth imbalance (as a difference) $$ \mbox{depth imbalance (as difference)}_t = \frac{D_t *(\mbox{OFRSIZ}_{t}-\mbox{BIDSIZ}_{t})}{(\mbox{OFRSIZ}_{t}+\mbox{BIDSIZ}_{t})}, $$ where \(D_t\) is 1 (-1) if \(trade_t\) was buy (sell) (see Boehmer (2005), Bessembinder (2003)). Note that the input of this function consists of the matched trades and quotes, so this is were the time indication refers to (and thus not to the registered quote timestamp).
depthImbalanceRatio: depth imbalance (as ratio) $$ \mbox{depth imbalance (as ratio)}_t = (\frac{\mbox{OFRSIZ}_{t}}{\mbox{BIDSIZ}_{t}})^{D_t}, $$ where \(D_t\) is 1 (-1) if \(trade_t\) was buy (sell) (see Boehmer (2005), Bessembinder (2003)). Note that the input of this function consists of the matched trades and quotes, so this is were the time indication refers to (and thus not to the registered quote timestamp).
proportionalEffectiveSpread: proportional effective spread $$ \mbox{proportional effective spread}_t = \frac{\mbox{effective spread}_t}{(\mbox{OFR}_{t}+\mbox{BID}_{t})/2} $$ (Venkataraman, 2001).
Note that the input of this function consists of the matched trades and quotes, so this is were the time indication refers to (and thus not to the registered quote timestamp).
proportionalRealizedSpread: proportional realized spread $$ \mbox{proportional realized spread}_t = \frac{\mbox{realized spread}_t}{(\mbox{OFR}_{t}+\mbox{BID}_{t})/2} $$ (Venkataraman, 2001).
Note that the input of this function consists of the matched trades and quotes, so this is were the time indication refers to (and thus not to the registered
priceImpact: price impact $$ \mbox{price impact}_t = \frac{\mbox{effective spread}_t - \mbox{realized spread}_t}{2} $$ (see Boehmer (2005), Bessembinder (2003)).
proportionalPriceImpact: proportional price impact $$ \mbox{proportional price impact}_t = \frac{\frac{(\mbox{effective spread}_t - \mbox{realized spread}_t)}{2}}{\frac{\mbox{OFR}_{t}+\mbox{BID}_{t}}{2}} $$ (Venkataraman, 2001). Note that the input of this function consists of the matched trades and quotes, so this is where the time indication refers to (and thus not to the registered quote timestamp).
halfTradedSpread: half traded spread $$ \mbox{half traded spread}_t = D_t*(\mbox{PRICE}_{t} - \frac{(\mbox{BID}_{t}+\mbox{OFR}_{t})}{2}), $$ where \(D_t\) is 1 (-1) if \(trade_t\) was buy (sell) (see Boehmer (2005), Bessembinder (2003)). Note that the input of this function consists of the matched trades and quotes, so this is were the time indication refers to (and thus not to the registered quote timestamp).
proportionalHalfTradedSpread: proportional half traded spread $$ \mbox{proportional half traded spread}_t = \frac{\mbox{half traded spread}_t}{\frac{\mbox{OFR}_{t}+\mbox{BID}_{t}}{2}}. $$ Note that the input of this function consists of the matched trades and quotes, so this is were the time indication refers to (and thus not to the registered quote timestamp).
squaredLogReturn: squared log return on trade prices $$ \mbox{squared log return on Trade prices}_t = (\log(\mbox{PRICE}_{t})-\log(\mbox{PRICE}_{t-1}))^2. $$
absLogReturn: absolute log return on trade prices $$ \mbox{absolute log return on Trade prices}_t = |\log(\mbox{PRICE}_{t})-\log(\mbox{PRICE}_{t-1})|. $$
quotedSpread: quoted spread $$ \mbox{quoted spread}_t = \mbox{OFR}_{t}-\mbox{BID}_{t} $$ Note that the input of this function consists of the matched trades and quotes, so this is where the time indication refers to (and thus not to the registered quote timestamp).
proportionalQuotedSpread: proportional quoted spread $$ \mbox{proportional quoted spread}_t = \frac{\mbox{quoted spread}_t}{\frac{\mbox{OFR}_{t}+\mbox{BID}_{t}}{2}} $$ (Venkataraman, 2001). Note that the input of this function consists of the matched trades and quotes, so this is where the time indication refers to (and thus not to the registered quote timestamp).
logQuotedSpread: log quoted spread $$ \mbox{log quoted spread}_t = \log(\frac{\mbox{OFR}_{t}}{\mbox{BID}_{t}}) $$
(Hasbrouck and Seppi, 2001). Note that the input of this function consists of the matched trades and quotes, so this is where the time indication refers to (and thus not to the registered quote timestamp).
logQuotedSize: log quoted size $$ \mbox{log quoted size}_t = \log(\mbox{OFRSIZ}_{t})-\log(\mbox{BIDSIZ}_{t}) $$
(Hasbrouck and Seppi, 2001). Note that the input of this function consists of the matched trades and quotes, so this is where the time indication refers to (and thus not to the registered quote timestamp).
quotedSlope: quoted slope $$ \mbox{quoted slope}_t = \frac{\mbox{quoted spread}_t}{\mbox{log quoted size}_t} $$ (Hasbrouck and Seppi, 2001).
logQSlope: log quoted slope $$ \mbox{log quoted slope}_t = \frac{\mbox{log quoted spread}_t}{\mbox{log quoted size}_t}. $$
midQuoteSquaredReturn: midquote squared return $$ \mbox{midquote squared return}_t = (\log(\mbox{midquote}_{t})-\log(\mbox{midquote}_{t-1}))^2, $$
where \(\mbox{midquote}_{t} = \frac{\mbox{BID}_{t} + \mbox{OFR}_{t}}{2}\).
midQuoteAbsReturn: midquote absolute return $$ \mbox{midquote absolute return}_t = |\log(\mbox{midquote}_{t})-\log(\mbox{midquote}_{t-1})|, $$
where \(\mbox{midquote}_{t} = \frac{\mbox{BID}_{t} + \mbox{OFR}_{t}}{2}\).
signedTradeSize: signed trade size $$ \mbox{signed trade size}_t = D_t * \mbox{SIZE}_{t},$$
where \(D_t\) is 1 (-1) if \(trade_t\) was buy (sell).
Bessembinder, H. (2003). Issues in assessing trade execution costs. Journal of Financial Markets, 223-257. Boehmer, E. (2005). Dimensions of execution quality: Recent evidence for US equity markets. Journal of Financial Economics 78 (3), 553-582. Hasbrouck, J. and D. J. Seppi (2001). Common factors in prices, order flows and liquidity. Journal of Financial Economics, 383-411. Venkataraman, K. (2001). Automated versus floor trading: An analysis of execution costs on the paris and new york exchanges. The Journal of Finance, 56, 1445-1485.
# NOT RUN {
tqData <- matchTradesQuotes(sampleTData, sampleQData)
res <- getLiquidityMeasures(tqData)
head(res)
# }
Run the code above in your browser using DataLab