|
||||||
Using Yahoo! Financial Stock QuotesHow to Access and Use On-Line Financial Data from Yahoo!
Yahoo! Financial stock quotes are free, on-line and can be accessed either via the Yahoo! web site or downloaded into Microsoft Excel or OpenOffice.org Calc
Yahoo! Finance is a free and easy to use on-line financial service which was used by more than 18 million people in May 2008 alone (according to the Internet analysis company comScore). This article will look at how anyone can obtain stock quotes from the Yahoo! Finance web site, and how to load those stock quotes into applications such as Microsoft Excel and OpenOffice.org Calc. Obtaining Yahoo! Finance Stock Quotes for a CompanyFor anyone with Internet access the easiest way to obtain stock quotes is to go directly to the Yahoo! Finance web site at http://finance.yahoo.com. Once there the user can get the current stock quote of any company in one of two ways:
For instance if micro is typed into the box then the suggestions will include:
It's then just a matter of selecting the correct company and the user will see that Microsoft (for instance) is currently up 0.19% at 26.30. Obtaining Yahoo! Finance Stock Quotes for Multiple CompaniesExamining the stock quote for an individual company is very informative, but if there are a number of companies to be viewed then this can be rather time consuming; therefore it's useful to know that it is possible to view the stock quotes of more than one company at the same time - and that's by entering the acronym for each company into the Yahoo! Finance text box and separating them using commas, for example: RHT,MSFT,NOVL
This time, as well as seeing the Microsoft stock quotes, the user would see that Red Hat is down 4.19% at 14.65 while Novell is up 1.19% at 5.00. Accessing the Yahoo! Finance Stock Quotes DirectlyHaving seen how to access stock quotes using the Yahoo! Finance web interface, it's worth noting that the current stock quotes can also be accessed directly by entering the correct URL into a web browser, for example:
http://finance.yahoo.com/q/cq?d=v1&s=RHT,MSFT,NOVL
Loading Yahoo! Finance Stock Quotes into Microsoft Excel or OpenOffice.org CalcUsers of Microsoft Excel or OpenOffice.org Calc can load the Yahoo! Finance stock quotes in one of three ways:
A Microsoft Excel Macro for Loading Yahoo! Finance Stock QuotesThe code for a Microsoft Excel that will download the Yahoo! Finance stock quotes is fairly simple, consisting of two subroutines; one to define the companies and fields, the other to format the URL to be used:
Sub getStocks ()
Dim companies As String
Dim fields As String
companies = "RHT,MSFT,NOVL"
fields = "sl1c1d1" ' symbol, last price, change and date
downloadStocks (companies, fields)
End Sub
Sub downloadStocks (companies As String, fields As string)
Dim url As String
url = "http://download.finance.yahoo.com/d/quotes.csv?" _
& "s=" & companies _
& "&f=" & fields & "&e=.csv"
Workbooks.Open Filename:= url
End Sub
An OpenOffice.org Calc Macro for Loading Yahoo! Finance Stock QuotesThe OpenOffice.org Calc code is slightly more complex than the Microsoft Excel code - the getStocks subroutine would be identical, but the downloadStocks subroutine would not (although it does the same job):
Sub getStocks ()
Dim companies As String
Dim fields As String
companies = "RHT,MSFT,NOVL"
fields = "sl1c1d1" ' symbol, last price, change and date
downloadStocks (companies, fields)
End Sub
sub downloadStocks (companies as String, fields as string)
dim url as string
dim doc
dim propertyValue(0) as new com.sun.star.beans.PropertyValue
url = "http://download.finance.yahoo.com/d/quotes.csv?" _
& "s=" & companies _
& "&f=" & fields & "&e=.csv"
propertyvalue(0).name = "FilterOptions"
propertyvalue(0).value ="44" 'csv
doc = stardesktop.loadcomponentfromurl _
(url, "_blank", 0, propertyvalue)
end sub
ConclusionYahoo! Finance stock quotes provide an easy to access and free data source; and the ability to either view the information on-line or to download it for future use make it an invaluable tool. Additional ReadingAn Introduction to Google Finance Accessing Yahoo! Finance from PHP
The copyright of the article Using Yahoo! Financial Stock Quotes in Computer Programming is owned by Mark Alexander Bain. Permission to republish Using Yahoo! Financial Stock Quotes in print or online must be granted by the author in writing.
|
||||||
|
|
||||||
|
|
||||||