The highfrequency package contains an extensive toolkit for the use of highfrequency financial data in R. It contains functionality to manage, clean and match highfrequency trades and quotes data. Furthermore, it enables users to: calculate easily various liquidity measures, estimate and forecast volatility, and investigate microstructure noise and intraday periodicity.
highfrequency::getLiquidityMeasures will report the following error when DIRECTION is all 1s:
Error in highfrequency::getLiquidityMeasures(matched, win = 300) :
DIRECTION provided, but is not -1 and 1
In addition: Warning message:
In if (sort(unique(tqData$DIRECTION)) != c(-1, 1)) { :
the condition has length > 1 and only the first element will be used
highfrequency::getLiquidityMeasures will report the following error when DIRECTION is all 1s: Error in highfrequency::getLiquidityMeasures(matched, win = 300) : DIRECTION provided, but is not -1 and 1 In addition: Warning message: In if (sort(unique(tqData$DIRECTION)) != c(-1, 1)) { : the condition has length > 1 and only the first element will be used
Can be reproduced with the following: df <- data.table(DT = c(as_datetime("2018-09-01 12:00:00"), as_datetime("2018-09-01 12:00:01"), as_datetime("2018-09-01 12:00:06")), SYMBOL = c("AAA", "AAA", "AAA"), BID = c( 2, 3, 3), OFR = c(1, 2, 3), OFRSIZ = c( 10, 10 ,10), BIDSIZ = c(10, 10 ,10), QUOTEXX = c("A"), MIDQUOTE = c(1.5, 2.5, 3), EX = c("A"), PRICE = c(2, 2, 2), SIZE = c(10, 10 ,10), DIRECTION = c(1, 1, 1) ) liq <- getLiquidityMeasures(df, win = 300)