[R-SIG-Finance] hdf5, quantmod, xts... and dates
Daniel Cegielka
daniel.cegielka at gmail.com
Wed Sep 16 15:21:44 CEST 2009
Hi
I try use hdf5 with quantmod and xts and I have some problems with dates.
Some ideas how can I restore the original date (or 'origin' parametr)?
regards
daniel cegielka
my session:
> library(hdf5)
> getSymbols('GOOG',from='2009-09-01')
[1] "GOOG"
> GOOG
GOOG.Open GOOG.High GOOG.Low GOOG.Close GOOG.Volume GOOG.Adjusted
2009-09-01 459.68 466.82 454.42 455.76 2594900 455.76
2009-09-02 455.82 458.33 452.59 453.01 1804800 453.01
2009-09-03 455.82 458.25 455.00 457.52 1646200 457.52
2009-09-04 457.57 462.60 455.78 461.30 1499200 461.30
2009-09-08 464.29 466.99 455.84 458.62 2656700 458.62
2009-09-09 459.06 466.27 458.80 463.97 2195400 463.97
2009-09-10 466.65 470.94 462.00 470.94 2534600 470.94
2009-09-11 470.40 473.30 467.63 472.14 1902900 472.14
2009-09-14 470.51 476.80 470.05 475.12 1975700 475.12
2009-09-15 475.08 478.91 472.71 477.54 2398100 477.54
> hdf5save('test.hdf','GOOG')
Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
> ls()
[1] "GOOG"
> rm(GOOG)
> ls()
character(0)
> hdf5load('test.hdf')
NULL
> ls()
[1] "GOOG"
> GOOG
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 459.68 466.82 454.42 455.76 2594900 455.76
[2,] 455.82 458.33 452.59 453.01 1804800 453.01
[3,] 455.82 458.25 455.00 457.52 1646200 457.52
[4,] 457.57 462.60 455.78 461.30 1499200 461.30
[5,] 464.29 466.99 455.84 458.62 2656700 458.62
[6,] 459.06 466.27 458.80 463.97 2195400 463.97
[7,] 466.65 470.94 462.00 470.94 2534600 470.94
[8,] 470.40 473.30 467.63 472.14 1902900 472.14
[9,] 470.51 476.80 470.05 475.12 1975700 475.12
[10,] 475.08 478.91 472.71 477.54 2398100 477.54
attr(,"index")
[1] 1251763200 1251849600 1251936000 1252022400 1252368000 1252454400
[7] 1252540800 1252627200 1252886400 1252972800
attr(,".indexCLASS")
[1] "Date"
attr(,".indexTZ")
[1] "GMT"
attr(,"src")
[1] "yahoo"
attr(,"updated")
[1] 1253104705
> xts(GOOG[,],as.Date(GOOG[,1]))
[,1] [,2] [,3] [,4] [,5] [,6]
1971-04-01 455.82 458.33 452.59 453.01 1804800 453.01
1971-04-01 455.82 458.25 455.00 457.52 1646200 457.52
1971-04-03 457.57 462.60 455.78 461.30 1499200 461.30
1971-04-05 459.06 466.27 458.80 463.97 2195400 463.97
1971-04-05 459.68 466.82 454.42 455.76 2594900 455.76
1971-04-10 464.29 466.99 455.84 458.62 2656700 458.62
1971-04-12 466.65 470.94 462.00 470.94 2534600 470.94
1971-04-16 470.40 473.30 467.63 472.14 1902900 472.14
1971-04-16 470.51 476.80 470.05 475.12 1975700 475.12
1971-04-21 475.08 478.91 472.71 477.54 2398100 477.54
> xts(GOOG[,],as.POSIXct(GOOG[,1],origin='1970-01-01'))
[,1] [,2] [,3] [,4] [,5] [,6]
1970-01-01 00:07:35 455.82 458.33 452.59 453.01 1804800 453.01
1970-01-01 00:07:35 455.82 458.25 455.00 457.52 1646200 457.52
1970-01-01 00:07:37 457.57 462.60 455.78 461.30 1499200 461.30
1970-01-01 00:07:39 459.06 466.27 458.80 463.97 2195400 463.97
1970-01-01 00:07:39 459.68 466.82 454.42 455.76 2594900 455.76
1970-01-01 00:07:44 464.29 466.99 455.84 458.62 2656700 458.62
1970-01-01 00:07:46 466.65 470.94 462.00 470.94 2534600 470.94
1970-01-01 00:07:50 470.40 473.30 467.63 472.14 1902900 472.14
1970-01-01 00:07:50 470.51 476.80 470.05 475.12 1975700 475.12
1970-01-01 00:07:55 475.08 478.91 472.71 477.54 2398100 477.54
> xts(GOOG[,],as.Date(GOOG[,1],origin='1970-01-01'))
[,1] [,2] [,3] [,4] [,5] [,6]
1971-04-01 455.82 458.33 452.59 453.01 1804800 453.01
1971-04-01 455.82 458.25 455.00 457.52 1646200 457.52
1971-04-03 457.57 462.60 455.78 461.30 1499200 461.30
1971-04-05 459.06 466.27 458.80 463.97 2195400 463.97
1971-04-05 459.68 466.82 454.42 455.76 2594900 455.76
1971-04-10 464.29 466.99 455.84 458.62 2656700 458.62
1971-04-12 466.65 470.94 462.00 470.94 2534600 470.94
1971-04-16 470.40 473.30 467.63 472.14 1902900 472.14
1971-04-16 470.51 476.80 470.05 475.12 1975700 475.12
1971-04-21 475.08 478.91 472.71 477.54 2398100 477.54
More information about the R-SIG-Finance
mailing list