gatherPrices {highfrequency}R Documentation

Make TAQ format

Description

Convenience function to gather data from one xts or data.table with at least "DT", and d columns containing price data to a "DT", "SYMBOL", and "PRICE" column. This function the opposite of spreadPrices.

Usage

gatherPrices(data)

Arguments

data

An xts or a data.table object with at least "DT" and d columns with price data with their names corresponding to the respective symbols.

Value

a data.table with columns DT, SYMBOL, and PRICE

Author(s)

Emil Sjoerup

See Also

spreadPrices

Examples

## Not run: 
library(data.table)
data1 <- copy(sampleTData)[,  `:=`(PRICE = PRICE * runif(.N, min = 0.99, max = 1.01),
                                               DT = DT + runif(.N, 0.01, 0.02))]
data2 <- copy(sampleTData)[, SYMBOL := 'XYZ']
dat1 <- rbind(data1[, list(DT, SYMBOL, PRICE)], data2[, list(DT, SYMBOL, PRICE)])
setkeyv(dat1, c("DT", "SYMBOL"))
dat1
dat <- spreadPrices(dat1) # Easy to use for realized measures
dat
dat <- gatherPrices(dat)
dat
all.equal(dat1, dat) # We have changed to RM format and back.

## End(Not run)

[Package highfrequency version 1.0.1 Index]