{
    "mode": "perldoc",
    "parameter": "Finance::Quote",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Finance%3A%3AQuote/json",
    "generated": "2026-06-15T11:15:15Z",
    "synopsis": "use Finance::Quote;\n$q = Finance::Quote->new;\n%quotes  = $q->fetch(\"nasdaq\", @stocks);",
    "sections": {
        "NAME": {
            "content": "Finance::Quote - Get stock and mutual fund quotes from various exchanges\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Finance::Quote;\n\n$q = Finance::Quote->new;\n%quotes  = $q->fetch(\"nasdaq\", @stocks);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module gets stock quotes from various internet sources all over the world. Quotes are\nobtained by constructing a quoter object and using the fetch method to gather data, which is\nreturned as a two-dimensional hash (or a reference to such a hash, if called in a scalar\ncontext). For example:\n\n$q = Finance::Quote->new;\n%info = $q->fetch(\"australia\", \"CML\");\nprint \"The price of CML is \".$info{\"CML\", \"price\"};\n\nThe first part of the hash (eg, \"CML\") is referred to as the stock. The second part (in this\ncase, \"price\") is referred to as the label.\n\nLABELS\nWhen information about a stock is returned, the following standard labels may be used. Some\ncustom-written modules may use labels not mentioned here. If you wish to be certain that you\nobtain a certain set of labels for a given stock, you can specify that using requirelabels().\n\nask          Ask\navgvol      Average Daily Vol\nbid          Bid\ncap          Market Capitalization\nclose        Previous Close\ncurrency     Currency code for the returned data\ndate         Last Trade Date  (MM/DD/YY format)\ndayrange    Day's Range\ndiv          Dividend per Share\ndivdate     Dividend Pay Date\ndivyield    Dividend Yield\neps          Earnings per Share\nerrormsg     If success is false, this field may contain the reason why.\nexdiv       Ex-Dividend Date.\nexchange     The exchange the information was obtained from.\nhigh         Highest trade today\nisin         International Securities Identification Number\nisodate      ISO 8601 formatted date\nlast         Last Price\nlow          Lowest trade today\nmethod       The module (as could be passed to fetch) which found this information.\nname         Company or Mutual Fund Name\nnav          Net Asset Value\nnet          Net Change\nopen         Today's Open\npchange     Percent Change from previous day's close\npe           P/E Ratio\nsuccess      Did the stock successfully return information? (true/false)\ntime         Last Trade Time\ntype         The type of equity returned\nvolume       Volume\nyearrange   52-Week Range\nyield        Yield (usually 30 day avg)\n\nIf all stock lookups fail (possibly because of a failed connection) then the empty list may be\nreturned, or undef in a scalar context.\n",
            "subsections": []
        },
        "INSTALLATION": {
            "content": "Please note that the Github repository is not meant for general users of Finance::Quote for\ninstallation.\n\nIf you downloaded the Finance-Quote-N.NN.tar.gz tarball from CPAN (N.NN is the version number,\nex: Finance-Quote-1.50.tar.gz), run the following commands:\n\ntar xzf Finance-Quote-1.50.tar.gz\ncd Finance-Quote-1.50.tar.gz\nperl Makefile.PL\nmake\nmake test\nmake install\n\nIf you have the CPAN module installed: Using cpanm (Requires App::cpanminus)\n\ncpanm Finance::Quote\n\nor Using CPAN shell\n\nperl -MCPAN -e shell\ninstall Finance::Quote\n",
            "subsections": []
        },
        "SUPPORT AND DOCUMENTATION": {
            "content": "After installing, you can find documentation for this module with the perldoc command.\n\nperldoc Finance::Quote\n\nYou can also look for information at:\n\nFinance::Quote GitHub project\nhttps://github.com/finance-quote/finance-quote\n\nSearch CPAN\nhttp://search.cpan.org/dist/Finance-Quote\n\nThe Finance::Quote home page\nhttp://finance-quote.sourceforge.net/\n\nThe Finance::YahooQuote home page\nhttp://www.padz.net/~djpadz/YahooQuote/\n\nThe GnuCash home page\nhttp://www.gnucash.org/\n",
            "subsections": []
        },
        "PUBLIC CLASS METHODS": {
            "content": "Finance::Quote implements public class methods for constructing a quoter object, getting or\nsetting default class values, and for listing available methods.\n\nnew\nmy $q = Finance::Quote->new()\nmy $q = Finance::Quote->new('-defaults')\nmy $q = Finance::Quote->new('AEX', 'Fool')\nmy $q = Finance::Quote->new(timeout => 30)\nmy $q = Finance::Quote->new('YahooJSON', fetchcurrency => 'EUR')\nmy $q = Finance::Quote->new('alphavantage' => {APIKEY => '...'})\nmy $q = Finance::Quote->new('IEXCloud', 'iexcloud' => {APIKEY => '...'});\nmy $q = Finance::Quote->new(currencyrates => {order => ['ECB', 'Fixer'], 'fixer' => {APIKEY => '...'}});\n\nFinance::Quote modules access a wide range of sources to provide quotes. A module provides one\nor more methods to fetch quotes. One method is usually the name of the module in lower case.\nOther methods, if provided, are descriptive names, such as 'canada', 'nasdaq', or 'nyse'.\n\nA Finance::Quote object uses one or more methods to fetch quotes for securities.\n\n\"new\" constructs a Finance::Quote object and enables the caller to load only specific modules,\nset parameters that control the behavior of the fetch method, and pass method specific\nparameters.\n\n\"timeout =\" T> sets the web request timeout to \"T\" seconds\n\"failover =\" B> where \"B\" is a boolean value indicating if failover in fetch is permitted\n\"fetchcurrency =\" C> sets the desired currency code to \"C\" for fetch results\n\"currencyrates =\" H> configures the order currency rate modules are consulted for exchange\nrates and currency rate module options\n\"requiredlabels =\" A> sets the required labels for fetch results to array \"A\"\n\"<ModuleName\"> as a string is the name of a specific Finance::Quote::Module to load\n\"<methodname\" => H> passes hash \"H\" to methodname during fetch to configure the method\n\nWith no arguments, \"new\" creates a Finance::Quote object with the default methods. If the\nenvironment variable FQLOADQUOTELET is set, then the contents of FQLOADQUOTELET (split on\nwhitespace) will be used as the argument list. This allows users to load their own custom\nmodules without having to change existing code. If any method names are passed to \"new\" or the\nflag '-defaults' is included in the argument list, then FQLOADQUOTELET is ignored.\n\nWhen new() is passed one or more class name arguments, an object is created with only the\nspecified modules loaded. If the first argument is '-defaults', then the default modules will be\nloaded first, followed by any other specified modules. Note that the FQLOADQUOTELET\nenvironment variable must begin with '-defaults' if you wish the default modules to be loaded.\n\nMethod names correspond to the Perl module in the Finance::Quote module space. For example,\n\"Finance::Quote-\"new('ASX')> will load the module Finance::Quote::ASX, which provides the method\n\"asx\".\n\nSome methods require API keys or have unique options. Passing 'method => HASH' to new() enables\nthe caller to provide a configuration HASH to the corresponding method.\n\nThe key 'currencyrates' configures the Finanace::Quote currency rate conversion. By default, to\nmaintain backward compatibility, Finance::Quote::CurrencyRates::AlphaVantage is used for\ncurrency conversion. This end point requires an API key, which can either be set in the\nenvironment or included in the configuration hash. To specify a different primary currency\nconversion method or configure fallback methods, include the 'order' key, which points to an\narray of Finance::Quote::CurrencyRates module names. See the documentation for the individual\nFinance::Quote::CurrencyRates to learn more.\n\ngetdefaultcurrencyfields\nmy @fields = Finance::Quote::getdefaultcurrencyfields();\n\n\"getdefaultcurrencyfields\" returns the standard list of fields in a quote that are\nautomatically converted during currency conversion. Individual modules may override this list.\n\ngetdefaulttimeout\nmy $value = Finance::Quote::getdefaulttimeout();\n\n\"getdefaulttimeout\" returns the current Finance::Quote default timeout in seconds for web\nrequests. Finance::Quote does not specify a default timeout, deferring to the underlying user\nagent for web requests. So this function will return undef unless \"setdefaulttimeout\" was\npreviously called.\n\nsetdefaulttimeout\nFinance::Quote::setdefaulttimeout(45);\n\n\"setdefaulttimeout\" sets the Finance::Quote default timeout to a new value.\n\ngetmethods\nmy @methods = Finance::Quote::getmethods();\n\n\"getmethods\" returns the list of methods that can be passed to \"new\" when creating a quoter\nobject and as the first argument to \"fetch\".\n",
            "subsections": []
        },
        "PUBLIC OBJECT METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "Btobillions",
                    "content": "my $value = $q->Btobillions(\"20B\");\n\n\"Btobillions\" is a utility function that expands a numeric string with a \"B\" suffix to the\ncorresponding multiple of 1000000000.\n\ndecimalshiftup\nmy $value = $q->decimalshiftup(\"123.45\", 1);  # returns 1234.5\nmy $value = $q->decimalshiftup(\"0.25\", 1);    # returns 2.5\n\n\"decimalshiftup\" moves a the decimal point in a numeric string the specified number of places\nto the right.\n\nfetch\nmy %stocks  = $q->fetch(\"alphavantage\", \"IBM\", \"MSFT\", \"LNUX\");\nmy $hashref = $q->fetch(\"nasdaq\", \"IBM\", \"MSFT\", \"LNUX\");\n\n\"fetch\" takes a method as its first argument and the remaining arguments are treated as\nsecurities. If the quoter $q was constructed with a specific method or methods, then only those\nmethods are available.\n\nWhen called in an array context, a hash is returned. In a scalar context, a reference to a hash\nwill be returned. The keys for the returned hash are \"{SECURITY,LABEL}\". For the above example\ncall, $stocks{\"IBM\",\"high\"} is the high value for IBM.\n\n$q->getmethods() returns the list of valid methods for quoter object $q. Some methods specify a\nspecific Finance::Quote module, such as 'alphavantage'. Other methods are available from\nmultiple Finance::Quote modules, such as 'nasdaq'. The quoter failover over option determines if\nmultiple modules are consulted for methods such as 'nasdaq' that more than one implementation.\n\ngetfailover\nmy $failover = $q->getfailover();\n\nFailover is when the \"fetch\" method attempts to retrieve quote information for a security from\nalternate sources when the requested method fails. \"getfailover\" returns a boolean value\nindicating if the quoter object will use failover or not.\n\nsetfailover\n$q->setfailover(False);\n\n\"setfailover\" sets the failover flag on the quoter object.\n\ngetfetchcurrency\nmy $currency = $q->getfetchcurrency();\n\n\"getfetchcurrency\" returns either the desired currency code for the quoter object or undef if\nno target currency was set during construction or with the \"setfetchcurrency\" function.\n\nsetfetchcurrency\n$q->setfetchcurrency(\"FRF\");  # Get results in French Francs.\n\n\"setfetchcurrency\" method is used to request that all information be returned in the specified\ncurrency. Note that this increases the chance stock-lookup failure, as remote requests must be\nmade to fetch both the stock information and the currency rates. In order to improve reliability\nand speed performance, currency conversion rates are cached and are assumed not to change for\nthe duration of the Finance::Quote object.\n\nSee the introduction to this page for information on how to configure the source of currency\nconversion rates.\n\ngetrequiredlabels\nmy @labels = $q->getrequiredlabels();\n\n\"getrequiredlabels\" returns the list of labels that must be populated for a security quote to\nbe considered valid and returned by \"fetch\".\n\nsetrequiredlabels\nmy $labels = ['close', 'isodate', 'last'];\n$q->setrequiredlabels($labels);\n\n\"setrequiredlabels\" updates the list of required labels for the quoter object.\n\ngettimeout\nmy $timeout = $q->gettimeout();\n\n\"gettimeout\" returns the timeout in seconds the quoter object is using for web requests.\n\nsettimeout\n$q->settimeout(45);\n\n\"settimeout\" updated the timeout in seconds for the quoter object.\n\nstoredate\n$quoter->storedate(\\%info, $stocks, {eurodate => '06/11/2020'});\n\n\"storedate\" is used by modules to consistent store date information about securities. Given the\nvarious pieces of a date, this function figures out how to construct a ISO date (yyyy-mm-dd) and\nUS date (mm/dd/yyyy) and stores those values in %info for security $stock.\n\ngetuseragent\nmy $ua = $q->getuseragent();\n\n\"getuseragent\" returns the LWP::UserAgent the quoter object is using for web requests.\n\nisoTime\n$q->isoTime(\"11:39PM\");    # returns \"23:39\"\n$q->isoTime(\"9:10 AM\");    # returns \"09:10\"\n\n\"isoTime\" returns an ISO formatted time.\n"
                }
            ]
        },
        "PUBLIC CLASS OR OBJECT METHODS": {
            "content": "The following methods are available as class methods, but can also be called from Finance::Quote\nobjects.\n\nscalefield\nmy $value = Finance::Quote->scalefield('1023', '0.01')\n\n\"scalefield\" is a utility function that scales the first argument by the second argument. In\nthe above example, \"value\" is '10.23'.\n\ncurrency\nmy $value = $q->currency('15.95 USD', 'AUD');\nmy $value = Finance::Quote->currency('23.45 EUR', 'RUB');\n\n\"currency\" converts a value with a currency code suffix to another currency using the current\nexchange rate as determined by the Finance::Quote::CurrencyRates method or methods configured\nfor the quoter $q. When called as a class method, only Finance::Quote::AlphaVantage is used,\nwhich requires an API key. See the introduction for information on configuring currency rate\nconversions and see Finance::Quote::CurrencyRates::AlphaVantage for information about the API\nkey.\n\ncurrencylookup\nmy $currency = $quoter->currencylookup();\nmy $currency = $quoter->currencylookup( name => \"Caribbean\");\nmy $currency = $quoter->currencyloopup( country => qw/denmark/i );\nmy $currency = $q->currencylookup(country => qr/united states/i, number => 840);\n\n\"currencylookup\" takes zero or more constraints and filters the list of currencies known to\nFinance::Quote. It returns a hash reference where the keys are ISO currency codes and the values\nare hash references containing metadata about the currency.\n\nA constraint is a key name and either a scalar or regular expression. A currency satisfies the\nconstraint if its metadata hash contains the constraint key and the value of that metadata field\nmatches the regular expression or contains the constraint value as a substring. If the metadata\nfield is an array, then it satisfies the constraint if any value in the array satisfies the\nconstraint.\n\nparsecsv\nmy @list = Finance::Quote::parsecsv($string);\n\n\"parsecsv\" is a utility function for splitting a comma separated value string into a list of\nterms, treating double-quoted strings that contain commas as a single value.\n\nparsecsvsemicolon\nmy @list = Finance::Quote::parsecsvsemicolon($string);\n\n\"parsecsv\" is a utility function for splitting a semicolon separated value string into a list\nof terms, treating double-quoted strings that contain semicolons as a single value.\n",
            "subsections": []
        },
        "LEGACY METHODS": {
            "content": "defaultcurrencyfields\nReplaced with getdefaultcurrencyfields().\n\nsources\nReplaced with getmethods().\n\nfailover\nReplaced with getfailover() and setfailover().\n\nrequirelabels\nReplaced with getrequiredlabels() and setrequiredlabels().\n\nuseragent\nReplaced with getuseragent().\n\nsetcurrency\nReplaced with getfetchcurrency() and setfetchcurrency().\n",
            "subsections": []
        },
        "ENVIRONMENT": {
            "content": "Finance::Quote respects all environment that your installed version of LWP::UserAgent respects.\nMost importantly, it respects the httpproxy environment variable.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "The caller cannot control the fetch failover order.\n\nThe two-dimensional hash is a somewhat unwieldly method of passing around information when\ncompared to references\n\nCOPYRIGHT & LICENSE\nCopyright 1998, Dj Padzensky\nCopyright 1998, 1999 Linas Vepstas\nCopyright 2000, Yannick LE NY (update for Yahoo Europe and YahooQuote)\nCopyright 2000-2001, Paul Fenwick (updates for ASX, maintenance and release)\nCopyright 2000-2001, Brent Neal (update for TIAA-CREF)\nCopyright 2000 Volker Stuerzl (DWS)\nCopyright 2001 Rob Sessink (AEX support)\nCopyright 2001 Leigh Wedding (ASX updates)\nCopyright 2001 Tobias Vancura (Fool support)\nCopyright 2001 James Treacy (TD Waterhouse support)\nCopyright 2008 Erik Colson (isoTime)\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the\nGNU General Public License as published by the Free Software Foundation; either version 2 of the\nLicense, or (at your option) any later version.\n\nCurrency information fetched through this module is bound by the terms and conditons of the data\nsource.\n\nOther copyrights and conditions may apply to data fetched through this module. Please refer to\nthe sub-modules for further information.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Dj Padzensky <djpadz@padz.net>, PadzNet, Inc.\nLinas Vepstas <linas@linas.org>\nYannick LE NY <y-le-ny@ifrance.com>\nPaul Fenwick <pjf@cpan.org>\nBrent Neal <brentn@users.sourceforge.net>\nVolker Stuerzl <volker.stuerzl@gmx.de>\nKeith Refson <Keith.Refson#earth.ox.ac.uk>\nRob Sessink <robses@users.sourceforge.net>\nLeigh Wedding <leigh.wedding@telstra.com>\nTobias Vancura <tvancura@altavista.net>\nJames Treacy <treacy@debian.org>\nBradley Dean <bjdean@bjdean.id.au>\nErik Colson <eco@ecocode.net>\n\nThe Finance::Quote home page can be found at http://finance-quote.sourceforge.net/\n\nThe Finance::YahooQuote home page can be found at http://www.padz.net/~djpadz/YahooQuote/\n\nThe GnuCash home page can be found at http://www.gnucash.org/\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Finance::Quote::CurrencyRates::AlphaVantage, Finance::Quote::CurrencyRates::ECB,\nFinance::Quote::CurrencyRates::Fixer, Finance::Quote::CurrencyRates::OpenExchange,\nFinance::Quote::AEX, Finance::Quote::ASEGR, Finance::Quote::ASX, Finance::Quote::Bloomberg,\nFinance::Quote::BSEIndia, Finance::Quote::Bourso, Finance::Quote::CSE,\nFinance::Quote::Cdnfundlibrary, Finance::Quote::Comdirect, Financ::Quote::Currencies,\nFinance::Quote::DWS, Finance::Quote::Deka, Finance::Quote::FTfunds, Finance::Quote::Fidelity,\nFinance::Quote::Finanzpartner, Finance::Quote::Fondsweb, Finance::Quote::Fool,\nFinance::Quote::Fundata Finance::Quote::GoldMoney, Finance::Quote::HU, Finance::Quote::IEXCloud,\nFinance::Quote::IndiaMutual, Finance::Quote::MStaruk, Finance::Quote::MorningstarAU,\nFinance::Quote::MorningstarJP, Finance::Quote::NSEIndia, Finance::Quote::NZX,\nFinance::Quote::OnVista, Finance::Quote::Oslobors, Finance::Quote::SEB, Finance::Quote::SIX,\nFinance::Quote::Tradeville, Finance::Quote::TSP, Finance::Quote::TMX, Finance::Quote::Tiaacref,\nFinance::Quote::Troweprice, Finance::Quote::USFedBonds, Finance::Quote::Union,\nFinance::Quote::YahooJSON, Finance::Quote::ZA\n\nYou should have received the Finance::Quote hacker's guide with this package. Please read it if\nyou are interested in adding extra methods to this package. The latest hacker's guide can also\nbe found on GitHub at\nhttps://github.com/finance-quote/finance-quote/blob/master/Documentation/Hackers-Guide\n",
            "subsections": []
        }
    },
    "summary": "Finance::Quote - Get stock and mutual fund quotes from various exchanges",
    "flags": [],
    "examples": [],
    "see_also": []
}