Hi, Yohan:

thanks for answering my question. It seems that the trick with try arguement doesn't work.

Imagine this is done in a loop and the process will die at ticker = 'ABI' and the rest of tickers leave no chance to read from yahoo. Of course I could be probe the ks site in the user code and catch the error before call yahooKeystats but this will be expensive. I think the efficient way has to be from fImport. Or do I miss something here?

 # IBM will not be able to run since ABI generates error and escaped
library(fImport);
tickers = c('ABI', 'IBM');
for (ticker in tickers) {
if (inherits(try({ks=yahooKeystats(ticker)}, silent = F), try-error)) {
print('no data');
}
}


--- On Tue, 3/31/09, Yohan Chalabi <chalabi@phys.ethz.ch> wrote:

From: Yohan Chalabi <chalabi@phys.ethz.ch>
Subject: Re: [R-SIG-Finance] fImport: yahooKeystats error
To: "Andy Zhu" <andyzhu35@yahoo.com>
Cc: r-sig-finance@stat.math.ethz.ch
Date: Tuesday, March 31, 2009, 3:43 AM

>>>> "AZ" == Andy Zhu <andyzhu35@yahoo.com>
>>>> on Mon, 30 Mar 2009 20:47:29 -0700 (PDT)

   AZ> How to catch error in this function? My following code seems
   AZ> not working with this fImport:
   AZ> library(fImport);
   AZ> ticker = 'ABI';
   AZ> if (inherits(try({ks=yahooKeystats(ticker)}, silent = F),
   AZ> try-error)) {
   AZ> print('no data');
   AZ> }

Hi Andy,

I would set the argument 'try' to FALSE  in 'yahooKeystats'.
This gives with your code  :

library(fImport);
ticker = 'ABI';
if (inherits(try({ks=yahooKeystats(ticker, try=FALSE)}, silent = F), "try-error")) {
print('no data');
}

But it would be better to cast the error you mentioned inside 
'yahooKeystats'. I will have a look at it when I have some spare time.

regards,
Yohan

-- 
PhD student
Swiss Federal Institute of Technology
Zurich

www.ethz.ch



      
	[[alternative HTML version deleted]]

