Due to the increased usage and amount of projects and utilities that can be found here on my developer blog, I have decided it is time to create a separate site for them allowing for users to find relevant examples and information easier. Therefore the MDBitz – Project Laboratory is know available. Currently I have ported over all the examples and information on the Harvest API and Yahoo Finance API Wrapper Libraries.

Slowly over the next few weeks/months I will be updating all the pages and content found in this blog to reflect the new site. In the mean time please be patient as the site maintenance is in progress.

, , ,

Today (March 12th, 2010) I released Version 1.2 of my YahooFinanceAPI PHP Wrapper Library. This version adds constants defining the Stock Options available from Yahoo Finance. A minor change to be sure, but one that can come in handy to those new to Stock Quotes and the available options.

All the constants are defined in the YahooFinance_Options class and are to be utilized when setting the options to be returned and when getting their values out of the returned stock quotes.

Setting the Options

$api->addOption( YahooFinance_Options::SYMBOL );
$api->addOption( YahooFinance_Options::PREVIOUS_CLOSE);
$api->addOption( YahooFinance_Options::OPEN );
$api->addOption( YahooFinance_Options::LAST_TRADE );

Getting the Stock Option value

$quote->get( YahooFinance_Options::SYMBOL );
$quote->get( YahooFinance_Options::PREVIOUS_CLOSE );
$quote->get( YahooFinance_Options::OPEN );
$quote->get( YahooFinance_Options::LAST_TRADE );

To see full sample code as well as staying up-to-date on changes to the library then please visit the PHP Wrapper Library for Yahoo Finance Stock Quotes API page that is maintained with the latest version for download and usage examples.

, , , , ,

Yesterday February 23rd, 2010 I released version 1.1 of my YahooFinanceAPI PHP library. This release adds in support for localization of the information so that you can get the stock quote time and date information in your local timezone, if Yahoo Finance supports your local.

To set your local simply set the local property of YahooFinanceAPI to a valid location.

$api->local = YahooFinance_Location::FRANCE;

To make it easier on users I have added the YahooFinance_Location class that contains constants of all the valid locals supported by Yahoo Finance. To see full sample code as well as staying up-to-date on changes to the library then please visit the PHP Wrapper Library for Yahoo Finance Stock Quotes API page that is maintained with the latest version for download and usage examples.

, , , , ,

For those that aren’t familiar with Yahoo Finance. They provide a simple api for obtaining information (quote) on stocks. To learn the basics of how it works you can read the post Yahoo Finance Stock API, and Understanding Yahoo Finance Stock Quotes and sl1d1t1c1ohgv which outlines the various information that you can request.

However these posts simply inform you of the United States Localized url for obtaining the information. For those in other parts of the world you can use a localized url to get time and date information based on your location. This is done by prepending the country code to the url. For example Germany would prepend de to the url and would download the information at:

http://de.finance.yahoo.com/d/quotes.csv?s=DELL&f=sl1d1t1c1ohgv&e=.csv

A full list of Country Codes can be found below.

Country Codes

Argentina ar
Australia au
Brazil br
Canada ca
France fr
Germany de
Hong Kong hk
India in
Ireland uk
Italy it
Korea kr
New Zealand au
Singapore sg
Spain es
United Kingdom uk

Also as Bastian pointed out in the comments the csv file does not use the , (comma) character as the delimiter for localizations that use commas instead of the period in displaying currency. In these cases the delimiter that is used is the ; (semicolon). The full list of countries with the different delimiter is below.

Localizations with ; delimiter

Argentina
Brazil
France
Germany
Italy
Spain
, , ,

To those just starting to utilize Yahoo Finance to obtain stock information you may get a little disoriented by the query string sl1d1t1c1ohgv. Although at first glance the string sl1d1t1c1ohgv may seem like random letters and numbers it is actually responsible for telling Yahoo Finance what information to return to you. Instead of sending dozens of individual parameters to determine what information to return Yahoo Finance choose to simply concatenate the variables together. Below is a breakdown of what stock information you can return in your quote.

Stock Quote Variables

Variable Description
a ask
a2 average daily volume
a5 ask size
b bid
b2 ask real time
b3 bid real time
b4 book value
b6 bid size
c change and percent change
c1 change
c3 commision
c6 change real time
c8 after hours change real time
d dividend per share
d1 last trade date
d2 trade date
e earnings per share
e1 error indication
e7 EPS estimate current year
e8 EPS estimate next year
e9 EPS estimate next quarter
f6 float shares
g days low
h days high
j 52 week low
k 52 week high
g1 holdings gain percent
g3 annualized gain
g4 holdings gain
g5 holdings gain percent real time
g6 holdings gain real time
i more info
i5 order book real time
j1 market capitalization
j3 market capitalization real time
j4 EBITDA
j5 change from 52 week low
j6 percent change from 52 week low
k1 last trade with time (real time)
k2 change percent real time
k3 last trade size
k4 change from 52 week high
k5 percent change from 52 week high
l last trade with time
l1 last trade
l2 high limit
l3 low limit
m days range
m2 days range real time
m3 50 day moving average
m4 200 day moving average
m5 change from 200 day moving average
m6 percent change from 200 day moving average
m7 change from 50 day moving average
m8 percent change from 50 day moving average
n name
n4 notes
o open
p previous close
p1 price paid
c2 change in percent
p5 price per sales
p6 price per book
q ex-dividend date
r price earnings ratio
r1 dividend pay date
r2 price earnings ratio real time
r5 PEG ratio
r6 price per EPS estimate current year
r7 price per EPS estimate next year
s symbol
s1 shares owned
s7 short ratio
t1 last trade time
t6 trade links
t7 ticker trend
t8 1 year target price
v volume
v1 holdings value
v7 holdings value real time
w 52 week range
w1 days value change
w4 days value change real time
x stock exchange
y dividend yield


So what doessl1d1t1c1ohgv stand for?

It tells Yahoo Finance to return the following information about the stock requested.

  • Symbol (s)
  • Last Trade Value (l1)
  • Lat Trade Date (d1)
  • Last Trade Time (t1)
  • Change (c1)
  • Open (o)
  • Days High (h)
  • Days Low (g)
  • Volume (v)

To make accessing the Yahoo Finance Stock Quote service easier for potential users, I have created a Yahoo Finance PHP Wrapper Library that you can utilize to query for stock quotes and information. The library returns the requested data as objects that you can easily extract information from, for full details visit the release page

Resources

, , , , ,