[R-SIG-Finance] rMetrics

Martin Becker martin.becker at mx.uni-saarland.de
Tue Jan 9 10:05:31 CET 2007


It seems to be a problem with locales. Yahoo returns US-month-names, but 
the corresponding code fragment in Rmetrics seems to use the current 
system locale for date conversion, and thus it may fail to convert the 
rownames to dates (for some months, resulting in NAs). Setting LC_TIME 
(temporarily) to US provides a quick fix.
[I am not sure, but maybe altering LC_TIME temporarily could be done by 
Rmetrics?]

See below for the (inserted) commands.

Kind regards,
  Martin Becker

genx schrieb:
> I am trying to download data off Yahoo finance utilizing the rMetrics
> packages but all the example code including several other examples found in
> the rMetrics PDFs fail. After a successful download of the data i get the
> following error message:
>
>
> trying URL
> 'http://chart.yahoo.com/table.csv?s=^DJI&a=0&b=1&c=1999&d=11&e=31&f=2000&x=.csv'
> Content type 'text/csv' length unknown
> opened URL
> downloaded 31Kb
>
> Read 504 items
> Read 7 items
> Error in if (sum(lt$sec + lt$min + lt$hour) == 0) isoFormat = "%Y-%m-%d" : 
>         missing value where TRUE/FALSE needed
>
>
> The .R code i am trying run looks like this (it's from the demo suite):
>
>     # Settings:
>     symbol = "^DJI"
>     file = "DJI.CSV"
>     source = "http://chart.yahoo.com/table.csv?"
>     # 1.1.1999 - 31.12.2000
>     # Note months count from 0 to 11 !
>     query = paste("s=", symbol,"&a=0&b=1&c=1999&d=11&e=31&f=2000&x=.csv", 
>         sep = "")
>     ###
>     
>     # Download: 
>     DJI = yahooImport(query, file, source, try = TRUE)
>     head(DJI at data)
>     ###
>   
tmp<-Sys.getlocale("LC_TIME")
Sys.setlocale("LC_TIME","US")

>         
>     # Direct data access as.timeSeries Object:
>     DJI = as.timeSeries(yahooImport(query, file, source, try = TRUE)@data)
>   
Sys.setlocale("LC_TIME",tmp)

>     class(DJI)
>     head(DJI)
>     tail(DJI)
>     ###
>
>
>
>



More information about the R-SIG-Finance mailing list