[R-SIG-Finance] Open to Close to Open data transformation (quantmod, xts and possibly zoo)

Costas Vorlow costas.vorlow at gmail.com
Fri Sep 23 11:50:28 CEST 2011


Hello,

I want to put in order (preferably as a zoo or xts object with a 
suitable timestamp)
the open anc closing prices of an (say) index downloaded from YAHOO finance:

require(quantmod)
getSymbols('^GSPC',from='1990-01-01')

medata<- tail((GSPC),400)
opens<-Op(medata)
closes<-Cl(medata)

i.e., I want  asingle sequence of  1095.89,    1105.24 , 1101.24 ,   
1102.94, and so on ... preferably with a timestamp (morning - evening of 
same day as for daily prices zoo does not like the same date in two 
consecutive prices...

 > head(merge(opens,closes))
            GSPC.Open GSPC.Close
2010-02-24   1095.89    1105.24
2010-02-25   1101.24    1102.94
2010-02-26   1103.10    1104.49
2010-03-01   1105.36    1115.71
2010-03-02   1117.01    1118.31
2010-03-03   1119.36    1118.79
 >
 >
Probably I could use the OpCl in quantmod and caclulate the Cl price 
from Op, though Is there any easy way using some implicit zoo/xts 
function for this? I have problems in puting the timestamps in the xts 
vobject.

Thanks,
Costas



More information about the R-SIG-Finance mailing list