Download the PHP package radicalloop/yahoo-finance-query without Composer
On this page you can find all versions of the php package radicalloop/yahoo-finance-query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download radicalloop/yahoo-finance-query
More information about radicalloop/yahoo-finance-query
Files in radicalloop/yahoo-finance-query
Package yahoo-finance-query
Short Description A PHP class to query the Yahoo Finance API
License MIT
Informations about the package yahoo-finance-query
YahooFinanceQuery
A PHP class to query the Yahoo Finance API.
Features
- search for symbol via Yahoo.Finance.Symbol.AutoSuggest
- query current quotes for symbols
- query historical quotes for single symbol
- query intraday quotes for single symbol
- query basic stock info
- query list of related stocks for index symbols
- query full list of sectors with related industries
Example
You can test an example.php at http://code.dirkolbrich.de/YahooFinanceQuery/
Installation
require via composer.json
in your project root
Implementation
As simple as that:
or as static:
Configuration
YahooFinanceQuery can be configured to return the data as an array or the raw json. Default returnType
is array
.
The config setting has to be passed as an array array('returnType' => 'array')
or array('returnType' => 'json')
.
At initialisation:
or as static:
At run-time:
The current config setting can be retrieved with:
To retrieve the raw cURL result use raw()
as addition to the query. This method must be called before the actural query method.
To force the query via the YQL api (if possible), use the yql()
method within the query string. This method must be called before the actural query method. The default is set to not use YQL, as I think YQL querys are unreliable and often with truncated results.
Usage
Querys are chainable. Use the get()
method to to retrieve the results.
The following query methods are available:
-
symbolSuggest($string)
Query for symbol suggestion via the YAHOO.Finance.SymbolSuggest.ssCallback
-
quote(array $symbol [, array $params])
Query for current quote for given symbols and given parameters.
The passed parameter
$symbol
must be an array. Several symbols can be passed.The passed parameter
$params
is optional and must be an array too. It accepts the parameters as a written word or as tags. See as reference the$quoteParams
variable in the class definition. If$params
is empty, the query will use all possible params.The params 'Symbol', 'LastTradeTime' and 'LastTradeDate' will be quered by default. There will be a unified UTC 'LastTradeTimestamp' added to the result array.
-
historicalQuote(array $symbol [, $startDate, $endDate, $param])
Query for historical quotes for given symbol with given start date and end date.
Only one
$symbol
can be passed per query and must be a string.$startDate
and$endDate
must be in the format YYYY-MM-DD. If no dates are passed, the query will grab all available historical quotes. If only one date is passed, the other one will be set to the maximum available.$param
is set to defaultd
= daily. See$historicalQuoteParams
variable for other options.I recommend not to use the
yql()
method with historical quotes, as the YQL console permits only up to 365 single result quotes. To retrieve a full set of historical quotes will not be possible via YQL. -
intraDay($symbol [, $period, $param])
Query finance.yahoo.com for intraday quotes. The symbol must be passed as as string.
$period
is optional and default set to1d
. It is possible to retrieve intraday quotes for up to the last 15 days.$param
is optional and default set toquote
. For other options see the$intraDayParams
variable. -
stockInfo($symbol)
Query finance.yahoo.com for basic stock information. The symbol must be passed as as string.
-
indexList(array $symbol)
Query for an index which returns the symbol and name of the components. Several symbols may be passed as an array.
See http://finance.yahoo.com/intlindices?e=europe for more symbols to world indices. The caret
^
character must be part of the symbol. -
sectorList()
Query for a complete list of sectors and their corresponding industries.
This function is static without any params.
Which returns an array in this form:
Recources
Some informative blog post and websites:
Yahoo YQL homepage
Blog post on that matter
Blog post from Joseph D. Purcell with an overview over finance API'S is a good entry point
www.gummy-stuff.org explains the Yahoo Finance .csv API
- http://www.gummy-stuff.org/Yahoo-data.htm Update on this: Yahoo harrased Mr. Ponzo about his documentation of a publicy available API and claimed some infringement on their TOS. But thanks to the internet archive, the last snapshot of this site is available at http://web.archive.org/web/20140527154306/http://www.gummy-stuff.org/Yahoo-data.htm
An overview over different api endpoints by Matthias Brusdeylins (german)
Tutorial for the YQL console by Thomas Belser (german)