spreadPrices {highfrequency} | R Documentation |
Convert to format for realized measures
Description
Convenience function to split data from one xts
or data.table
with at least "DT"
, "SYMBOL"
, and "PRICE"
columns to a format
that can be used in the functions for calculation of realized measures.
This is the opposite of gatherPrices
.
Usage
spreadPrices(data)
Arguments
data |
An |
Value
An xts
or a data.table
object with columns "DT"
and
a column named after each unique entrance in the "SYMBOL"
column of the input.
These columns contain the price of the associated symbol. We drop all other columns, e.g. SIZE
.
Author(s)
Emil Sjoerup.
See Also
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']
dat <- rbind(data1, data2)
setkey(dat, "DT")
dat <- spreadPrices(dat)
rCov(dat, alignBy = 'minutes', alignPeriod = 5, makeReturns = TRUE, cor = TRUE)
## End(Not run)
[Package highfrequency version 1.0.1 Index]