Quantmod,来自Google的getSymbols中的空日期

时间:2013-12-09 13:55:47

标签: r quantmod google-finance

Quantmod版本0.4.0

当使用Google作为源时,函数getSymbols返回空日期,而不是使用Yahoo。

谷歌数据似乎很好,检查http://www.google.com/finance/historical?cid=700196&startdate=Sep+30%2C+2010&enddate=Nov+1%2C+2010&num=30&ei=6sqlUoieA5SLsgfq5gE&output=csv

可以使用以下代码重现:

library(quantmod)

Sys.setenv(TZ="UTC")

DataG <- getSymbols('XLF',src="google",auto.assign=FALSE, from = '2010-09-30', to = '2010-11-01')

DataG

DataY <- getSymbols('XLF',src="yahoo",auto.assign=FALSE, from = '2010-09-30', to = '2010-11-01')

DataY

在版本0.4.1中重新测试,仍然是NA的日期!

  

DataG&lt; - getSymbols('XLF',src =“google”,auto.assign = FALSE,from ='2010-09-30',to ='2010-11-01')   DataG

       XLF.Open XLF.High XLF.Low XLF.Close XLF.Volume
2010-09-30    14.46    14.63   14.34     14.34  107539828
<NA>          14.49    14.55   14.34     14.50  132131830
<NA>          14.48    14.59   14.33     14.40   85547602
<NA>          14.53    14.78   14.42     14.73  133006599
<NA>          14.76    14.80   14.67     14.72   64754368
<NA>          14.79    14.84   14.58     14.66   71795649
<NA>          14.68    14.73   14.62     14.70   62422677
<NA>          14.71    14.73   14.62     14.68   41265794
<NA>          14.60    14.87   14.57     14.84   65831033
<NA>          14.94    15.00   14.82     14.86  112666954
<NA>          14.72    14.75   14.46     14.60  169232668
<NA>          14.64    14.72   14.25     14.34  132860239
<NA>          14.30    14.69   14.30     14.67   78307701
<NA>          14.56    14.77   14.41     14.47  146739470
<NA>          14.48    14.69   14.35     14.61   96600861
<NA>          14.67    14.78   14.49     14.61   73596983
<NA>          14.64    14.69   14.56     14.60   41264255
<NA>          14.73    14.75   14.53     14.55   45766940
<NA>          14.49    14.60   14.46     14.57   47408863
<NA>          14.52    14.63   14.47     14.58   62701109
<NA>          14.66    14.70   14.49     14.58   57911184
<NA>          14.54    14.59   14.48     14.56   39827062
2010-11-01    14.59    14.69   14.42     14.56   65746592
  

DataY&lt; - getSymbols('XLF',src =“yahoo”,auto.assign = FALSE,from ='2010-09-30',to ='2010-11-01')   DATAY

       XLF.Open XLF.High XLF.Low XLF.Close XLF.Volume XLF.Adjusted
2010-09-30    14.46    14.63   14.34     14.35  107532900        13.65
2010-10-01    14.49    14.55   14.34     14.50  132129000        13.80
2010-10-04    14.48    14.59   14.33     14.40   85547600        13.70
2010-10-05    14.53    14.79   14.42     14.73  133006600        14.01
2010-10-06    14.76    14.80   14.67     14.72   64754400        14.01
2010-10-07    14.79    14.84   14.58     14.66   71794600        13.95
2010-10-08    14.68    14.73   14.62     14.70   62412700        13.99
2010-10-11    14.71    14.73   14.62     14.68   41265800        13.97
2010-10-12    14.60    14.87   14.57     14.85   65831100        14.13
2010-10-13    14.94    15.00   14.82     14.86  112667000        14.14
2010-10-14    14.72    14.75   14.46     14.60  169232700        13.89
2010-10-15    14.65    14.72   14.25     14.35  132854700        13.65
2010-10-18    14.30    14.69   14.30     14.67   78305300        13.96
2010-10-19    14.56    14.77   14.41     14.47  146739500        13.77
2010-10-20    14.48    14.69   14.35     14.61   96600900        13.90
2010-10-21    14.67    14.78   14.49     14.61   73588900        13.90
2010-10-22    14.64    14.69   14.56     14.60   41264300        13.89
2010-10-25    14.73    14.75   14.53     14.55   45766800        13.84
2010-10-26    14.49    14.60   14.46     14.57   47400100        13.86
2010-10-27    14.52    14.63   14.47     14.58   62701200        13.87
2010-10-28    14.66    14.70   14.49     14.58   57907600        13.87
2010-10-29    14.54    14.59   14.48     14.56   39826600        13.85
2010-11-01    14.59    14.69   14.42     14.56   65743100        13.85
  

installed.packages()[“quantmod”,“Version”]   [1]“0.4-1”

1 个答案:

答案 0 :(得分:3)

本地化和日期格式存在问题。这对我有用。

invisible(Sys.setlocale("LC_MESSAGES", "C"))
invisible(Sys.setlocale("LC_TIME", "C"))

现在尝试以谷歌作为数据源的getSymbols。