spreadPrices: Convert to format for realized measures

View source: R/dataHandling.R

spreadPricesR 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 xts or a data.table object with at least "DT", "SYMBOL", and "PRICE" columns. This data should already be cleaned.

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

gatherPrices

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)

jonathancornelissen/highfrequency documentation built on Jan. 10, 2023, 7:29 p.m.