Skip to content
Prev 1580 / 15274 Next

RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all?

Diethelm,
Thank you for your response. Asyt.ts in my example is a timeSeries object
constructed using yahooSeries(). Trying out the example you provided I get:
trying URL
'http://chart.yahoo.com/table.csv?s=IBM&a=7&b=12&c=2006&d=7&e=12&f=2007&g=d&
x=.csv'
Content type 'text/csv' length unknown
opened URL
downloaded 12Kb

Read 250 items
Error in matrix(unlist(x2), byrow = TRUE, nrow = length(x2)) : 
        matrix: invalid 'ncol' value (< 0)
Error in .yahooSeries(symbols[1], from = from, to = to, nDaysBack =
nDaysBack,  : 
        cannot get a slot ("data") from an object of type "character"

After applying the patch to yahooImport() that I posted in my initial
message the import works:
trying URL
'http://chart.yahoo.com/table.csv?s=IBM&a=7&b=12&c=2006&d=7&e=12&f=2007&g=d&
x=.csv'
Content type 'text/csv' length unknown
opened URL
downloaded 12Kb

Read 250 items
Read 7 items
[1] "IBM.Open"   "IBM.High"   "IBM.Low"    "IBM.Close"  "IBM.Volume"

Given that plot() has been overloaded to deal with timeSeries objects I
would have expected it to have some default functionality when passed a
timeSeries object short of unceremoniously failing in a lower level function
call. I did not realize it only works on single columns/data series.

As for ohlcDailyPlot(), I checked the source code later on and realized that
it expects column names that are different from how the market data
retrieval functions construct their timeSeries objects. This is easily
adjusted for. However, it's not exactly a smooth solution from a design
point of view. Also, the documentation does not mention the need for an
explicit prior call to par(mfrow = c(2, 1)) for it to result in a proper
plot. But I guess maybe that's obvious to a more seasoned R user than me.

Anyway, thank you for pointing me in the right direction. The code in
yahooImport(), however, really is broken as you can clearly verify by taking
a look at the date format delivered by Yahoo which does not have spelled out
three letter month names as expected by the source code.

David

-----Original Message-----
From: Diethelm Wuertz [mailto:wuertz at itp.phys.ethz.ch] 
Sent: Sunday, August 12, 2007 6:06 PM
To: David-Michael Lincke; r-sig-finance at stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] RMetrics fBasics market data retrieval and
timeSeries functionality still being maintained at all?
David-Michael Lincke wrote:
all?
What is your test ? --- useless if you don't tell us what you have done
This is wrong what you tell us.

Have you read the help pages ? --- I think definitely not.

yahooImport() is a function which delivers a web object of the download 
with many
information which is helpful for downloading data on a regular time 
schedule and to
store them in a database. Nota bene, there is a data slot which keeps 
the timeSeries
object.

For simply downloading a time series, you should use the function 
yahooSeries(). This
delivers a 'timeSeries' object.

Note, the download depends on the time format used by Yahoo. This has 
changed a few
months ago, noticed on this mailing list. --- Therefore you should use a 
recent version of
Rmetrics and you should also update your software on a regular base.
functionality
No, definitely not ...

Try ...

IBM = yahooSeries("IBM")
colnames(IBM)
par(mfrow = c(1,1))
plot(IBM[, "IBM.Open"], type = "l")
lines(IBM[, "IBM.Close"],col = "red")

Rmetrics has also many tailored plotting functions, plot is only
used for univariate timeSeries objects, multivariate timeSeries
objects can be displayed using the additional functions lines()
and points()!
What is asyt.ts ? --- We can only help if you tell us what you have done ...
ylab[1])
I wan't comment this ....

ohlcDailyPlot() expects a timeSeries object with column names c("Open", 
"High", "Low", "Close", "Volume")
They can be in any order, but the names must be exactly the column names 
mentioned.

Try:

colnames(IBM) <- c("Open", "High", "Low", "Close", "Volume")
par(mfrow = c(2, 1))
ohlcDailyPlot(IBM)


... it works fine!

Diethelm

Thread (12 messages)

David-Michael Lincke RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all? Aug 10 Jeff Ryan RMetrics fBasics market data retrieval andtimeSeries functionality still being maintained at all? Aug 10 Diethelm Wuertz RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all? Aug 12 David-Michael Lincke RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all? Aug 12 Martin Maechler RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all? Aug 14 David-Michael Lincke RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all? Aug 14 Adam Gehr RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all? Aug 14 Dirk Eddelbuettel RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all? Aug 14 Praveen Kanakamedala RMetrics fBasics market data retrieval and timeSeries functionality still being maintained at all? Aug 14 David-Michael Lincke RMetrics fBasics market data retrieval andtimeSeries functionality still being maintained at all? Aug 14 Brian G. Peterson RMetrics fBasics market data retrieval andtimeSeries functionality still being maintained at all? Aug 14 Martin Maechler RMetrics fBasics market data retrieval andtimeSeries functionality still being maintained at all? Aug 15