jonathancornelissen / highfrequency

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.
147 stars 63 forks source link

Error in min(selection):max(selection) while using the vol function #80

Open MislavSag opened 2 years ago

MislavSag commented 2 years ago

Hi,

I am trying to use businessTimeAggregation function with vol (volatility) as measure:

library(QuantTools)
library(highfrequency)

# import data and cleaning
ticks <- get_finam_data("AAPL", as.Date("2021-09-01"), as.Date("2021-09-02"), "tick")
setnames(ticks, c("DT", "PRICE", "SIZE"))
ticks$SYMBOL <- "AAPL"
ticks_cleaned <- tradesCleanup(tDataRaw = ticks)
ticks_cleaned <- ticks_cleaned$tData

# aggreagtion
vol_bars <- businessTimeAggregation(ticks_cleaned, measure = "vol")

but got an error:

Error in min(selection):max(selection) : 
  result would be too long a vector
In addition: Warning messages:
1: In detPer(mR, rData = rData, options = options) :
  Periodicity estimation is unstable when the sample data contains less than 50 days. The quality of results may vary
2: In min(selection) : no non-missing arguments to min; returning Inf
3: In max(selection) : no non-missing arguments to max; returning -Inf

I have also tried with more than 50days of data, but got the same error.

onnokleen commented 1 year ago

The QuantTools package is not supported anymore but I think I found your error. It could be that there are too many zero-returns at the same time across days. I'll improve the error messages.

MislavSag commented 1 year ago

Hello, thanks for the answer. This is an old issue, but I will try again soon since I have just starterd to work with highfrequency package few days before, after some time.... I want close an issue, since you said you will add some error messages...