Question

I know that there are other similar posts, but I still couldn't figure out how to coerce the data I had to an XTS object.

https://quantquote.com/sample/SPY_MINUTE_TRADE.csv contains a csv file of minute bar data of the SPY.

Column 1 is Data in YYYYMMDD format. Column 2 is Time in HHMM format.

I want to create an XTS object indexed in a very standard YYYY-MM-DD-HH-MM format.

I have been told that using read.zoo to import the csv is a good way to do it but can't seem to make it work.

Any advice on how to about it?

EDIT: Almost there but I'm still missing something

datzoo <- read.zoo(file="SPY_MINUTE_TRADE.csv", sep=",", header=TRUE, index.column=1:2,
                   format="%Y%m%d %H%M", tz="", colClasses = rep(c("character", "numeric"), c(2, 8)))

RETURNS

Error in read.zoo(file = "SPY_MINUTE_TRADE.csv", sep = ",", header = TRUE, : index has 210 bad entries at data rows: 1 2 3 4 5 6 7 8 9 10 11....

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top