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

aggregateTS changes input object #76

Closed MislavSag closed 2 years ago

MislavSag commented 3 years ago

I would like to post one inconvenience IMHO. Using aggregateTS changes input DT, probably by reference. Here is an example:

library(QuantTools)
library(highfrequency)

# import data and cleaning
tick_data <- get_finam_data("AAPL", as.Date("2021-09-07"), as.Date("2021-09-07"), "tick")
setnames(tick_data, c("DT", "PRICE", "SIZE"))
tick_data$SYMBOL <- "AAPL"
tick_data_cleaned <- tradesCleanup(tDataRaw = tick_data)
print(tick_data_cleaned$report)
tick_data_cleaned <- tick_data_cleaned$tData
head(tick_data_cleaned)
bars <- aggregateTS(tick_data_cleaned, alignBy = "minutes", alignPeriod = 1)
head(tick_data_cleaned)

You can see how tick_data_cleaned object changes after applying aggregateTS function on it. I am not sure if this is on purpose, but I would like more to keep my object as it is.

MislavSag commented 3 years ago

I know I can copy my tick_data_cleaned object and than delete it afterwards. But not sure if this is how you expect to be used...