$OpenBSD: patch-lib_Finance_QuoteHist_Generic_pm,v 1.2 2003/09/23 18:38:04 sturm Exp $ --- lib/Finance/QuoteHist/Generic.pm.orig 2003-01-16 17:38:20.000000000 +1100 +++ lib/Finance/QuoteHist/Generic.pm 2003-09-02 01:34:03.000000000 +1000 @@ -24,6 +24,7 @@ my @Scalar_Flags = qw( ratio_precision attempts reverse + reverse_fetch adjusted has_non_adjusted env_proxy @@ -298,7 +299,13 @@ sub target_get { my(@rows, %empty_fetch, %saw_good_rows); foreach my $s ($self->symbols) { - foreach ($self->$urlmaker($s)) { + my @urllist; + if ($self->{reverse_fetch}) { + @urllist = reverse ($self->$urlmaker($s)); + } else { + @urllist = ($self->$urlmaker($s)); + } + foreach (@urllist) { if ($empty_fetch{$s}) { print STDERR ref $self, " passing on $s ($target) for now, empty fetch\n" @@ -551,7 +558,9 @@ sub rows { # Prep the rows foreach (@$rows) { + next if (!defined($_)); foreach (@$_) { + next if (!defined($_)); # Zap leading and trailing white space s/^\s+//; s/\s+$//; @@ -709,6 +718,11 @@ sub non_quote_row { my @non_quotes; foreach (0 .. $#$row) { next if $_ == $dcol; + # Rows which have undefined fields + # (Yahoo include "date,dividend" in with the quotes) + if (!defined($row->[$_])) { + return $row; + } next if $row->[$_] =~ /^\s*$/; if ($row->[$_] !~ /^\s*\$*[\d\.,]+\s*$/) { return $row; @@ -1191,6 +1205,24 @@ flag. If the overall order is not that i flag. Typically, site-specific sub classes of this module will take care of setting this appropriately. The default is 0. +=item reverse_fetch + +(The default value is 0.) + +If true, we fetch each batch of rows in the reverse order to that +provided by C. + +Note that the order of rows within blocks is not affected, +so you might get orders like 7,8,9, 4,5,6, 1,2,3. + +Background: I was trying to use Finance::QuoteHist to 'backfill' +data for current ASX symbols from 1990 to today. When I asked for a +start date too early the Yahoo server returned a header with no data +blocks. After more than C failures the fetch was aborted. +By requesting the blocks in the reverse order I get all the data. +I assume this would not work for any symbols without quotes within +the most recent requested block (ie defunct symbols). + =item attempts Sets how persistently the module tries to retrieve the quotes. There