stocksCRSPxts function

Select CRSP Stocks Returns

Select CRSP Stocks Returns

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

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.

Returns

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))
  • Maintainer: Doug Martin
  • License: GPL-2
  • Last published: 2023-08-30

Useful links