Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

problem getting splits with Finance::QuoteHist-1.12

by Foxpond Hollow (Sexton)
on May 23, 2010 at 22:49 UTC ( #841293=perlquestion: print w/replies, xml ) Need Help??

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 (Archbishop) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://841293]
Approved by GrandFather
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2022-05-26 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (93 votes). Check out past polls.

    Notices?