| spreadPrices | R Documentation |
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.
spreadPrices(data)
data |
An |
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.
Emil Sjoerup.
gatherPrices
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.