reliability problem with Finance::QuoteHist::Yahoo



I have been able to get this package to work sometimes. However,
invariably it fails on me part way through my script, after
downloading data for from one to four ticker symbols. The error is:

Can't use an undefined value as an ARRAY reference at C:/Perl/site/lib/
Finance/QuoteHist/Generic.pm line 863.

I have no information about how an undefined value is being passed
deep into the code of a package I didn't write. I took a quick look
into Generic.pm and yahoo.pm, but found no enlightenment so far
(there's a lot of code there).

Sometimes it arises when quotes() is executed, and at other times, it
occurs when dividends() is executed.

The script I am using is appended below. There isn't anything special
about it. Much of it I copied from example code in the documentation
provided for the two finance packages I'm trying. About all I did was
merge two example scripts, and attempt to get the historical quote
data for one symbol at a time. So far, I have historical quote data
for four stocks. There are over 7000 that I need to retrieve:
obviously not something that is manageable manually downloading each
individually.

Neither Finance::QuoteHist::Generic nor Finance::QuoteHist::Yahoo
(which is derived from the former) say anything about error handling,
or provide a way to test whether or not data was successfully
downloaded.

Any assistance would be greatly appreciated.

Thanks

Ted

use Finance::TickerSymbols;
use Finance::QuoteHist::Yahoo;
use IO::File;

#my $fh1 = new IO::File "> values.csv";
#my $fh2 = new IO::File "> splits.csv";
#my $fh3 = new IO::File "> dividends.csv";
my $fname1;
my $fname2;
my $fname3;

for my $industry ( industries_list()) {
print "\n\n$industry\n";
mkdir "$industry";
for my $symbol ( industry_list( $industry ) ) {
print "$symbol\n\n";
mkdir "$industry\\$symbol";
$fname1 = "$industry\\$symbol\\values.csv";
$fname2 = "$industry\\$symbol\\splits.csv";
$fname3 = "$industry\\$symbol\\dividends.csv";
$fh1 = new IO::File "> $fname1";
$fh2 = new IO::File "> $fname2";
$fh3 = new IO::File "> $fname3";
$q = new Finance::QuoteHist::Yahoo
(
symbols => "$symbol",
start_date => '01/01/1998',
end_date => 'today'
);
# Values
foreach $row ($q->quotes()) {
if (defined $row ) {
($symbol, $date, $open, $high, $low, $close, $volume) = @$row;
print $fh1 "$symbol, $date, $open, $high, $low, $close, $volume
\n";
} else {
print "No data for $symbol\n";
next;
}
}
$fh1->close();
foreach $row ($q->splits()) {
if (defined $row ) {
($symbol, $date, $post, $pre) = @$row;
print $fh2 "$symbol, $date, $post, $pre\n";
} else {
print "No splits data for $symbol\n";
next;
}
}
$fh2->close();
foreach $row ($q->dividends()) {
if (defined $row ) {
($symbol, $date, $dividend) = @$row;
print $fh3 "$symbol, $date, $dividend\n";
} else {
print "No dividend data for $symbol\n";
next;
}
}
$fh3->close();
}
}
.



Relevant Pages

  • Re: critcl and packages
    ... I was trying to produce a sample package as described in the critcl ... The script seems to run OK as a script but it fails when trying to ... ("foreach" body line 32) ...
    (comp.lang.tcl)
  • Installation of software, and security. . .
    ... installation in Windows and various package managers. ... A setup.exe program coded by some third party such as Real Networks ... A .msi Microsoft Installer package is unpacked, and a script coded by ...
    (Bugtraq)
  • Re: dclusr trick no longer works with the Turbo Explorers
    ... If it's just a matter of downloading a tweak to be able to install ... any package, don't you think it'll affect sales? ...
    (borland.public.delphi.non-technical)
  • Re: goto &Package::func destroying @_?!
    ... >>script, but maybe the description will trigger something from someone.... ... code the 'Core' package uses another package as a base that has a custom ... package Foo; ... if it really is a problem with goto&. ...
    (comp.lang.perl.misc)
  • Re: ActiveX Script errors suppressed
    ... I've never actually tried to call GetExecutionErrorInfo in an ActiveX ... >etc. ActiveX Script only has the variant type. ... >change the variant to a true string. ... Dynamic Properties task instead in the main package. ...
    (microsoft.public.sqlserver.dts)