Financ...teHist(3pm)

πŸ’– Finance::QuoteHist β€” the manual, but make it a group chat πŸ’–

okay bestie, so this is the perl documentation for Finance::QuoteHist(3pm), a Perl module for fetching historical stock quotes. yes, the stock quotes. from the web. we're getting rich (or at least getting data) ✨


🌸 SYNOPSIS 🌸

here's the whole vibe in code, no cap:

  use Finance::QuoteHist;
  $q = Finance::QuoteHist->new
     (
      symbols    => [qw(IBM UPS AMZN)],
      start_date => '01/01/2009', # or '1 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');

like look at her go. quotes, splits, dividends, and then the lil snitch quote_source telling you who actually did the fetching. iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Finance::QuoteHist is the top level interface for fetching historical stock quotes from the web. main character energy, honestly.

here's the tea: it's actually a front end to modules based on Finance::QuoteHist::Generic, and the one big difference is that this one comes with a default lineup of web sites</> it'll try to pull quotes from. if the thought of mixing data from multiple sites has you stressed (valid), then just use one of the site-specific modules directly instead. do what feels right 🫢

unless you set it yourself via the lineup attribute, this module will pick a lineup for you, and the default is:

    Finance::QutoeHist::Yahoo
    Finance::QutoeHist::Google

once it's instantiated, this module acts identically to the first module in the lineup and shares all of that module's methods. it's giving "i'm the group project leader but actually i just delegate."

most queries will probably be handled by that first module in the lineup. but if the site is down for some reason, or maybe that site just doesn't have quotes for some defunct ticker symbol, then the other sites in the lineup get their turn. teamwork, baby 🌈

for the gory details on all the parameters and methods this module accepts, go read Finance::QuoteHist::Generic(3). the basic interface is right below tho, don't worry.


✨ METHODS ✨

the basic user interface is a few methods, exactly like in the example up there. and they are:

  • quotes() β€” returns a list of rows (or a reference to an array holding those rows, if you're in scalar context). each row has the Symbol, Date, Open, High, Low, Close, and Volume for that date. and optionally, if you asked for non-adjusted values, there'll be an extra element at the end of the row for the Adjusted closing price. extra lil bonus element, we love her πŸŽ€
  • dividends() β€” returns a list of rows (or a reference to an array holding those rows, if you're in scalar context). each row has the Date and the amount of the Dividend, in that order. money moves πŸ’Έ
  • splits() β€” returns a list of rows (or a reference to an array holding those rows, if you're in scalar context). each row has the Date, the Post split shares, and the Pre split shares, in that order. order matters bestie, don't swap them 😭
  • source($ticker, $target) β€” each of these methods shows you which site-specific class actually retrieved the info, if any, for a particular ticker symbol and target β€” like 'quote' (that's the default), 'dividend', or 'split'. it's the receipts. the culprit reveal πŸ”₯

πŸ’€ DISCLAIMER πŸ’€

okay this is the serious part, so listen up:

the data returned from these modules is in no way guaranteed, and the developers are not responsible in any way for how this data (or the lack thereof) gets used. none of it. zero. πŸ™ˆ

the interface is based on URLs and page layouts that might change at any time. even though these modules are designed to be adaptive under those circumstances, at some point they will probably not be able to retrieve data unless they get fixed or get fed new parameters. that's just how it is.

and also β€” the data from these web sites usually isn't even guaranteed by the web sites themselves, and it's oftentimes acquired from somewhere else entirely. for more info on the disclaimer for a specific site, read that site-specific module's documentation. check your sources, bestie 🧚


πŸ‘‘ AUTHOR πŸ‘‘

Matthew P. Sisk, <sisk@mojotoad.com>


Copyright (c) 2000-2021 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

("All wrongs revenged" is genuinely the hardest line in software licensing and i will not be taking questions πŸ’…)


🌈 SEE ALSO 🌈


and that's the whole page, bestie!! this was perl v5.32.1, dated 2021-03-12 β€” go forth and fetch those historical quotes responsibly, mwah 🫢✨🌸

πŸ“¦ where this page comes from