stocksCRSPxts {PCRA}R Documentation

Select CRSP Stocks Returns

Description

A function to extract a subset of the stocksCRSP data.table specified by a date range and a set of tickers, with convenient defaults, and convert it to an xts object

Usage

stocksCRSPxts(
  data,
  dateRange = c("1993-01-31", "2015-12-31"),
  tickerSet = NULL
)

Arguments

data

One of the data.table objects stocksCRSP, stocksCRSPweekly, stocksCRSPdaily

dateRange

Character vector with two components a start date and an end date using format "yyyy-mm-dd". Default is the entire stocksCRSP data dates range c("1993-01-31","2015-12-32")

tickerSet

A subset of tickers of the stocks in stocksCRSP. The default is tickerSet = NULL, which results in selection of all stocks in stocksCRSP.

Value

A multivariate xts object of stock returns

Examples

data.table::setDTthreads(1)
library(PCRA)
library(xts)
library(data.table)
class(stocksCRSP)
args(stocksCRSPxts)
tickers4 <- c("DHR","CSL","AVP","AMWD")
dateRange <- c("2011-01-31","2015-12-31")
returns4 <- stocksCRSPxts(stocksCRSP, dateRange = dateRange,
                           tickerSet = tickers4) 
class(returns4)
dim(returns4)
names(returns4)
range(index(returns4))                         

[Package PCRA version 1.2 Index]