Foxpond Hollow has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I'm having a problem fetching splits with Finance::QuoteHist-1.12. My actual code is long and gross and most of it irrelevant to this problem (or I would assume anyway). I get the same problem using the basic sample code in the module documentation:
use Finance::QuoteHist; $q = Finance::QuoteHist->new ( symbols => [qw(IBM UPS AMZN)], start_date => '01/01/2008', # or 'one year ago', see Date::Manip end_date => 'today', ); # Quotes foreach $row ($q->quotes()) { ($symbol, $date, $open, $high, $low, $close, $volume) = @$row; } # Splits foreach $row ($q->splits()) { ($symbol, $date, $post, $pre) = @$row; } # Dividends foreach $row ($q->dividends()) { ($symbol, $date, $dividend) = @$row; } # Culprit $fetch_class = $q->quote_source('IBM');
Here is the error I get:
Use of uninitialized value $args[0] in join or string at /usr/local/Ac +tivePerl-5.10/site/lib/Date/Manip.pm line 134. Problem parsing date string '' at splitTest.pl line 15
I'm not sure if this is an error on my part somehow or a glitch in the module, and I wanted to run it by the monks before submitting a bug report. Because I get the error with the module's sample code, I'm assuming it's not a problem with my own code but let me know if you feel it would be useful to post that too and I will. Thanks.

Replies are listed 'Best First'.
Re: problem getting splits with Finance::QuoteHist-1.12
by Khen1950fx (Canon) on May 24, 2010 at 06:10 UTC
    I get the same error. I looked at the source for Finance::QuoteHist, and it appears to use multiple engines, but when I ran it, it only used Finance::QuoteHist::Yahoo. That might be the source of the problem. According to the docs: "Splits are only available embedded in the HTML version of dividends". It could be that to get splits and dividends, you'll need to use the extractors method, but I didn't see any documentation for it.

    Here's what I managed to get, sans splits and dividends:

    #!/usr/bin/perl use strict; no warnings; use Data::Dumper::Perltidy; use Finance::QuoteHist; my $q = Finance::QuoteHist->new ( symbols => [qw(IBM)], start_date => '05/20/2010', end_date => 'today', ); foreach my $row ($q->quotes()) { my($symbol, $date, $open, $high, $low, $close, $volume) = @$row; } print Dumper($q);
      I changed two lines in the module Yahoo.pm and now it works fine.

      These two lines:

      #foreach (grep(/\w+/, split(/\s*,\s+/, $split_line))) {
        #my($date, $post, $pre) = /^(\S+)\D*(\d+):(\d+)/m;
      
      to these ones
      foreach (grep(/\w+/, (split /(=?+\],*)/, $split_line))) {
       my($date, $post, $pre) = /^(.+)\[(\d+):(\d+)/m;
      
      Hope is works for you. IsaacN
Re: problem getting splits with Finance::QuoteHist-1.12
by choroba (Cardinal) on May 23, 2010 at 23:09 UTC
    Not exactly related to your problem, but: 'one year ago' is not parsable by Date::Manip. '1 year ago', on the other hand, is.