returnsCRSPxts function

Select CRSP Stocks Returns

Select CRSP Stocks Returns

Uses selectCRSPandSPGMI to select a subset of the stocksCRSP data, and convert it to an xts object that contains the returns of a set of stocks, along with those of the MktIndexCRSP and the Ret13WkBill.

NOTE: For this function to work, the selectCRSPandSPGMI must include the the stockItems TickerLast, MktIndexCRSP and Ret13WkBill.

returnsCRSPxts(stocksData)

Arguments

  • stocksData: The data.table created by selectCRSPandSPGMI

Returns

A multivariate xts object

Examples

data.table::setDTthreads(1) library(PCRA) library(xts) library(data.table) stockItems <- c("Date","TickerLast","CapGroupLast","Return","MktIndexCRSP", "Ret13WkBill") dateRange <- c("1997-01-31","2002-12-31") stocksDT <- selectCRSPandSPGMI("monthly",dateRange = dateRange, stockItems = stockItems, factorItems = NULL, outputType = "data.table") stocksDT <- stocksDT[CapGroupLast == "SmallCap"] ret <- returnsCRSPxts(stocksDT) tickers <- unique(stocksDT[,TickerLast]) tickers10 <- tickers[11:20] colnames <- c(tickers10,"Market","RiskFree") head(ret[,colnames],1)
  • Maintainer: Doug Martin
  • License: GPL-2
  • Last published: 2023-08-30

Useful links