Learn R Programming

highfrequency (version 0.5.3)

tqLiquidity: Calculate numerous (23) liquidity measures

Description

Function returns an xts object containing one of the following liquidity measures:

es, rs, value_trade, signed_value_trade, di_diff, di_div, pes, prs, price_impact, prop_price_impact, tspread, pts, p_return_sqr, p_return_abs, qs, pqs, logqs, logsize, qslope, logqslope, mq_return_sqr, mq_return_abs.

Usage

tqLiquidity(tqdata,tdata,qdata,type,...)

Arguments

tqdata

xts object, containing joined trades and quotes (e.g. using matchTradesQuotes)

tdata

xts-object containing the trade data.

qdata

xts-object containing the quote data.

type

a character vector containing the name of one of the above mentioned liquidity measures, e.g. type="es" to get the effective spread.

...

additional arguments.

Value

an xts object containing one of the above mentioned liquidity measures.

Details

The respective liquidity measures are defined as follows:

  • es: effective spread $$ \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).

  • rs: 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.

  • value_trade: trade value $$ \mbox{trade value}_t = \mbox{SIZE}_{t}*\mbox{PRICE}_{t}. $$

  • signed_value_trade: 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)).

  • di_diff: depth imbalance (as a difference) $$ \mbox{depth imbalace (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).

  • di_div: depth imbalace (as ratio) $$ \mbox{depth imbalace (as ratio)}_t = (\frac{D_t *\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).

  • pes: 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).

  • prs: 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

  • price_impact: price impact $$ \mbox{price impact}_t = \frac{\mbox{effective spread}_t - \mbox{realized spread}_t}{2} $$ (see Boehmer (2005), Bessembinder (2003)).

  • prop_price_impact: 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).

  • tspread: 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).

  • pts: 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).

  • p_return_sqr: squared log return on trade prices $$ \mbox{squared log return on Trade prices}_t = (\log(\mbox{PRICE}_{t})-\log(\mbox{PRICE}_{t-1}))^2. $$

  • p_return_abs: absolute log return on trade prices $$ \mbox{absolute log return on Trade prices}_t = |\log(\mbox{PRICE}_{t})-\log(\mbox{PRICE}_{t-1})|. $$

  • qs: 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).

  • pqs: 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).

  • logqs: 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).

  • logsize: 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).

  • qslope: 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}. $$

  • mq_return_sqr: 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}\).

  • mq_return_abs: 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}\).

  • signed_trade_size: 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).

References

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.

Examples

Run this code
# NOT RUN {
#load data samples
data("sample_tdata");
data("sample_qdata");
tdata = sample_tdata;
qdata = sample_qdata;
#match the trade and quote data
tqdata = matchTradesQuotes(tdata,qdata);

#calculate the proportional realized spread:
prs = tqLiquidity(tqdata,tdata,qdata,type="prs");

#calculate the effective spread:
es = tqLiquidity(tqdata,type="es");
# }

Run the code above in your browser using DataLab