ch.claudio.finance
Class Yahoo

java.lang.Object
  extended by ch.claudio.finance.Yahoo

public class Yahoo
extends java.lang.Object

Represent (part of) the information one can get about a stock from Yahoo. This class represents a single ticker.

Information for a single ticker is requested by issuing a GET request similar to this:

 http://finance.yahoo.com/d/quotes.csv?s=AAPL&f=i5x
 

where the value of s is the ticker symbol and the value of f is the format string composed of a sequence of keys. E.g. in the example the two keys i5 and x. Note: x is a shorthand for x0.

Indexes can be retrieved, they have a special symbol starting with a caret (^). Additionally an index can be preceded by an at (@) sign in which case all tickers belonging to the index are retrieved. Such ticker are rejected by this class as it can not handle responses consisting of several lines. Note: Some server limit the number of lines returned on such a request.

Currency exchange rates can be fetched using symbols of the from CCCccc=X where CCC is one currency and ccc another currency and X is the letter X, e.g. EURCHF=X.

The meaning of those keys can be seen from the following table. Any letter/number combination not mentioned was omitted because it was never observed to return something different than "-", "N/A" or an empty string.

*
a0 Ask
a2 Average Daily Volume
a3 Unknown. Not implemented.
a4 Unknown. Not implemented.
a5 Ask Size. Can contain commas as thousands separator!
b0 Bid
b1 Unknown. Not implemented.
b2 Ask (Market/Real-time)
b3 Bid (Market/Real-time)
b4 Book Value
b6 Bid Size. Can contain commas as thousands separator!
c0 Change and Percent Change. Only c6 was implemented.
c1 Change
c2 Unknown. Not implemented.
c3 Commission
c4 Currency
c5 Unknown. Not implemented.
c6 Change (Market/Real-time)
c7 Unknown. Not implemented.
c8 After Hours Change (Market/Real-time). Not (yet?) implemented.
d0 Dividend/Share
d1 Last Trade Date (Format m/d/y)
d2 Trade Date (Format m/d/y)
d3 Trade(?) Time (e.g. 6:31am). Time replaced by date if before today, e.g. Mar 25)
e0 Earnings/Share
e1 Error Indication (returned for symbol changed / invalid)
e7 EPS Estimate Current Year
e8 EPS Estimate Next Year
e9 EPS Estimate Next Quarter
f6 Float Shares. Can contain commas as thousands separator!
g0 Day's Low
g1 Holdings Gain Percent. Not (yet?) implemented.
g3 Annualized Gain
g4 Holdings Gain
g5 Holdings Gain Percent (Market/Real-time). Not (yet?) implemented.
g6 Holdings Gain (Market/Real-time)
h0 Day's High
i0 More Info
i5 Order Book (Market/Real-time)
i7 Unknown. Not implemented.
j0 52-week Low
j1 Market Capitalization
j2 Unknown. Not implemented. Can contain commas as thousands separator!
j3 Market Cap (Market/Real-time)
j4 EBITDA
j5 Change From 52-week Low
j6 Percent Change From 52-week Low. Not (yet?) implemented.
k0 52-week High
k1 Last Trade (Market/Real-time with Time). Not (yet?) implemented.
k2 Change Percent (Market/Real-time). Not (yet?) implemented.
k3 Last Trade Size. Can contain commas as thousands separator!
k4 Change From 52-week High
k5 Percent Change From 52-week High. Not (yet?) implemented.
l0 Last Trade (With Time). Only l1 implemented.
l1 Last Trade (Price Only)
l2 High Limit
l3 Low Limit
l7 Unknown. Not implemented.
l8 Unknown. Not implemented.
l9 Unknown. Not implemented.
m0 Day's Range. Only g0 and h0 implemented.
m2 Day's Range (Market/Real-time). Not (yet?) implemented.
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. Not implemented, please compute as m5/m4.
m7 Change From 50-day Moving Average
m8 Percent Change From 50-day Moving Average. Not implemented, please compute as m7/m3.
n0 Name
n1 Unknown. Not implemented.
n4 Notes
n5 Unknown. Not implemented.
o0 Open
p0 Previous Close
p1 Price Paid
p2 Change in Percent
p4 Unknown. Not implemented.
p5 Price/Sales
p6 Price/Book
p8 Unknown. Not implemented.
p9 Unknown. Not implemented.
q0 Ex-Dividend Date
q1 Unknown. Not implemented.
q2 Unknown. Not implemented.
r0 P/E Ratio
r1 Dividend Pay Date
r2 P/E (Market/Real-time)
r5 PEG Ratio
r6 Price/EPS Estimate Current Year
r7 Price/EPS Estimate Next Year
s0 Symbol
s1 Shares Owned
s2 Unknown. Not implemented.
s4 Unknown. Not implemented.
s6 Unknown. Not implemented.
s7 Short Ratio
t1 Last Trade Time
t5 Unknown. Not implemented.
t6 Trade Links. Not (yet?) implemented.
t7 Ticker Trend. Not (yet?) implemented.
t8 1-yr Target Price
v0 Volume
v1 Holdings Value
v2 Unknown. Not implemented.
v6 Unknown. Not implemented.
v7 Holdings Value (Market/Real-time)
w0 52-week Range. Only implemented j0 and k0.
w1 Day's Value Change. Not (yet?) implemented.
w4 Day's Value Change (Market/Real-time). Not (yet?) implemented.
x0 Stock Exchange
y0 Dividend Yield
y1 Unknown. Not implemented.
y2 Unknown. Not implemented.

The following codes return preformatted HTML snippets which are ignored by this class: f0-f5. f7-f8, g2, h1-h6, q3-q9, r3-r4, t0, t2, t6-t7, u0, u2-u3, z0-z2 and z4-z7.

Not used in this class but noted here for completness, the Yahoo historical data. It can be requested by issuing a GET request to e.g.

  http://ichart.finance.yahoo.com/table.csv?s=AAPL&a=2&b=1&c=2005&d=2&e=5&f=2005&g=d
 

one can obtain a csv list of Open, Close, High and Low price and Volume for the specified date range.

a=start month
b=start day
c=start year
d=end month
e=end day
f=end year
g=(d,w,y,v) with d=daily,w=weekly,y=yearly,v=dividends and splits
s=symbol

Version:
$Id: Yahoo.java 237 2008-03-28 20:14:22Z claudio $
Author:
Claudio Nieder

Copyright (C) 2006-2008 Claudio Nieder <private@claudio.ch>, CH-8610 Uster

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA


Field Summary
static ch.claudio.finance.Yahoo.ServerDesc serverAR
          Server descriptor for Argentinian server.
static ch.claudio.finance.Yahoo.ServerDesc serverAU
          Server descriptor for Austrlaian server.
static ch.claudio.finance.Yahoo.ServerDesc serverBR
          Server descriptor for Brasilian server.
static ch.claudio.finance.Yahoo.ServerDesc serverCA
          Server descriptor for Canadian server.
static ch.claudio.finance.Yahoo.ServerDesc serverCF
          Server descriptor for African server.
static ch.claudio.finance.Yahoo.ServerDesc serverDE
          Server descriptor for German server.
static ch.claudio.finance.Yahoo.ServerDesc serverES
          Server descriptor for Spanish server.
static ch.claudio.finance.Yahoo.ServerDesc serverFR
          Server descriptor for French server.
static ch.claudio.finance.Yahoo.ServerDesc serverHK
          Server descriptor for Hongkong server.
static ch.claudio.finance.Yahoo.ServerDesc serverIN
          Server descriptor for Indian server.
static ch.claudio.finance.Yahoo.ServerDesc serverIT
          Server descriptor for Italian server.
static ch.claudio.finance.Yahoo.ServerDesc serverKR
          Server descriptor for Korean server.
static ch.claudio.finance.Yahoo.ServerDesc serverMX
          Server descriptor for Mexican server.
static ch.claudio.finance.Yahoo.ServerDesc serverOldDE
          Server descriptor for alternate German server.
static ch.claudio.finance.Yahoo.ServerDesc serverOldES
          Server descriptor for alternate Spanish server.
static ch.claudio.finance.Yahoo.ServerDesc serverOldFR
          Server descriptor for alternate French server.
static ch.claudio.finance.Yahoo.ServerDesc serverOldIT
          Server descriptor for alternate Italian server.
static ch.claudio.finance.Yahoo.ServerDesc serverOldUK
          Server descriptor for alternate British server.
static ch.claudio.finance.Yahoo.ServerDesc serverSG
          Server descriptor for Singapour server.
static ch.claudio.finance.Yahoo.ServerDesc serverUK
          Server descriptor for British server.
static ch.claudio.finance.Yahoo.ServerDesc serverUS
          Server descriptor for US server.
 
Constructor Summary
Yahoo(java.lang.String tickerArg)
          Create an object for a ticker symbol using the US server.
Yahoo(ch.claudio.finance.Yahoo.ServerDesc server, java.lang.String tickerArg)
          Create an object for a ticker symbol using a specific server
 
Method Summary
 java.lang.Double getAnnualizedGain()
           
 java.lang.Double getAsk()
           
 java.lang.Double getAskMarket()
           
 java.lang.Long getAskSize()
           
 java.lang.Long getAverageDailyVolume()
           
 java.lang.Double getAvg200()
           
 java.lang.Double getAvg200Change()
           
 java.lang.Double getAvg50()
           
 java.lang.Double getAvg50Change()
           
 java.lang.Double getBid()
           
 java.lang.Double getBidMarket()
           
 java.lang.Long getBidSize()
           
 java.lang.Double getBookValue()
           
 java.lang.Double getChange()
           
 java.lang.Double getChangeMarket()
           
 java.lang.Double getCommission()
           
 java.lang.String getCurrency()
           
 java.lang.Double getDayHigh()
           
 java.lang.Double getDayLow()
           
 java.lang.Double getDividend()
           
 java.util.Date getDividendPayDate()
           
 java.lang.Double getDividendYield()
           
 java.lang.Double getEbitda()
           
 java.lang.Double getEps()
           
 java.lang.Double getEpsCurrentYear()
           
 java.lang.Double getEpsNextQuarter()
           
 java.lang.Double getEpsNextYear()
           
 java.lang.String getError()
           
 java.util.Date getExDividendDate()
           
 java.lang.Long getFloatShares()
           
 java.lang.Double getHighLimit()
           
 java.lang.Double getHoldingsGain()
           
 java.lang.Double getHoldingsGainMarket()
           
 java.lang.Double getHoldingValue()
           
 java.lang.Double getHoldingValueMarket()
           
 java.lang.String getInfo()
           
 java.lang.Double getLastTrade()
           
 java.util.Date getLastTradeDate()
           
 java.lang.Long getLastTradeSize()
           
 long getLastUpdate()
           
 java.lang.Double getLowLimit()
           
 java.lang.Double getMarketCap()
           
 java.lang.Double getMarketCapMarket()
           
 java.lang.String getName()
           
 java.lang.String getNotes()
           
 java.lang.Double getOpen()
           
 java.lang.String getOrderBook()
           
 java.lang.Double getPegRatio()
           
 java.lang.Double getPreviousClose()
           
 java.lang.Double getPriceEarningRatio()
           
 java.lang.Double getPriceEarningRatioMarket()
           
 java.lang.Double getPricePaid()
           
 java.lang.Double getPricePerBooks()
           
 java.lang.Double getPricePerEPSCurrentYear()
           
 java.lang.Double getPricePerEPSNextYear()
           
 java.lang.Double getPricePerSales()
           
 java.lang.String getRequestedTicker()
           
 java.lang.Long getSharesOwned()
           
 java.lang.Double getShortRatio()
           
 java.lang.String getStockExchange()
           
 java.lang.Double getTargetPriceOneYear()
           
 java.lang.String getTicker()
           
 java.util.Date getTradeDate()
           
 java.lang.Long getVolume()
           
 java.lang.Double getYearHigh()
           
 java.lang.Double getYearHighChange()
           
 java.lang.Double getYearLow()
           
 java.lang.Double getYearLowChange()
           
static void main(java.lang.String[] args)
          Print license.
 void refreshInfo()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serverAR

public static final ch.claudio.finance.Yahoo.ServerDesc serverAR
Server descriptor for Argentinian server.


serverAU

public static final ch.claudio.finance.Yahoo.ServerDesc serverAU
Server descriptor for Austrlaian server.


serverBR

public static final ch.claudio.finance.Yahoo.ServerDesc serverBR
Server descriptor for Brasilian server.


serverCA

public static final ch.claudio.finance.Yahoo.ServerDesc serverCA
Server descriptor for Canadian server.


serverCF

public static final ch.claudio.finance.Yahoo.ServerDesc serverCF
Server descriptor for African server.


serverDE

public static final ch.claudio.finance.Yahoo.ServerDesc serverDE
Server descriptor for German server.


serverES

public static final ch.claudio.finance.Yahoo.ServerDesc serverES
Server descriptor for Spanish server.


serverFR

public static final ch.claudio.finance.Yahoo.ServerDesc serverFR
Server descriptor for French server.


serverHK

public static final ch.claudio.finance.Yahoo.ServerDesc serverHK
Server descriptor for Hongkong server.


serverIN

public static final ch.claudio.finance.Yahoo.ServerDesc serverIN
Server descriptor for Indian server.


serverIT

public static final ch.claudio.finance.Yahoo.ServerDesc serverIT
Server descriptor for Italian server.


serverKR

public static final ch.claudio.finance.Yahoo.ServerDesc serverKR
Server descriptor for Korean server.


serverMX

public static final ch.claudio.finance.Yahoo.ServerDesc serverMX
Server descriptor for Mexican server.


serverSG

public static final ch.claudio.finance.Yahoo.ServerDesc serverSG
Server descriptor for Singapour server.


serverUK

public static final ch.claudio.finance.Yahoo.ServerDesc serverUK
Server descriptor for British server.


serverUS

public static final ch.claudio.finance.Yahoo.ServerDesc serverUS
Server descriptor for US server.


serverOldDE

public static final ch.claudio.finance.Yahoo.ServerDesc serverOldDE
Server descriptor for alternate German server.


serverOldES

public static final ch.claudio.finance.Yahoo.ServerDesc serverOldES
Server descriptor for alternate Spanish server.


serverOldFR

public static final ch.claudio.finance.Yahoo.ServerDesc serverOldFR
Server descriptor for alternate French server.


serverOldIT

public static final ch.claudio.finance.Yahoo.ServerDesc serverOldIT
Server descriptor for alternate Italian server.


serverOldUK

public static final ch.claudio.finance.Yahoo.ServerDesc serverOldUK
Server descriptor for alternate British server.

Constructor Detail

Yahoo

public Yahoo(ch.claudio.finance.Yahoo.ServerDesc server,
             java.lang.String tickerArg)
Create an object for a ticker symbol using a specific server

Parameters:
server -
tickerArg -

Yahoo

public Yahoo(java.lang.String tickerArg)
Create an object for a ticker symbol using the US server.

Parameters:
tickerArg -
Method Detail

refreshInfo

public void refreshInfo()
                 throws java.net.MalformedURLException,
                        java.io.IOException
Throws:
java.io.IOException
java.net.MalformedURLException

getLastUpdate

public long getLastUpdate()
Returns:
the lastUpdate

getAverageDailyVolume

public java.lang.Long getAverageDailyVolume()
Returns:
the averageDailyVolume

getAskSize

public java.lang.Long getAskSize()
Returns:
the askSize

getAsk

public java.lang.Double getAsk()
Returns:
the ask

getRequestedTicker

public java.lang.String getRequestedTicker()
Returns:
the requestedTicker

getDividendPayDate

public java.util.Date getDividendPayDate()
Returns:
the dividendPayDate

getExDividendDate

public java.util.Date getExDividendDate()
Returns:
the exDividendDate

getLastTradeDate

public java.util.Date getLastTradeDate()
Returns:
the lastTradeDate

getTradeDate

public java.util.Date getTradeDate()
Returns:
the tradeDate

getAnnualizedGain

public java.lang.Double getAnnualizedGain()
Returns:
the annualizedGain

getAskMarket

public java.lang.Double getAskMarket()
Returns:
the askMarket

getAvg200

public java.lang.Double getAvg200()
Returns:
the avg200

getAvg200Change

public java.lang.Double getAvg200Change()
Returns:
the avg200Change

getAvg50

public java.lang.Double getAvg50()
Returns:
the avg50

getAvg50Change

public java.lang.Double getAvg50Change()
Returns:
the avg50Change

getBid

public java.lang.Double getBid()
Returns:
the bid

getBidMarket

public java.lang.Double getBidMarket()
Returns:
the bidMarket

getBookValue

public java.lang.Double getBookValue()
Returns:
the bookValue

getChange

public java.lang.Double getChange()
Returns:
the change

getChangeMarket

public java.lang.Double getChangeMarket()
Returns:
the changeMarket

getCommission

public java.lang.Double getCommission()
Returns:
the commission

getCurrency

public java.lang.String getCurrency()
Returns:
the currency

getDayHigh

public java.lang.Double getDayHigh()
Returns:
the dayHigh

getDayLow

public java.lang.Double getDayLow()
Returns:
the dayLow

getDividend

public java.lang.Double getDividend()
Returns:
the dividend

getDividendYield

public java.lang.Double getDividendYield()
Returns:
the dividendYield

getEbitda

public java.lang.Double getEbitda()
Returns:
the ebitda

getEps

public java.lang.Double getEps()
Returns:
the eps

getEpsCurrentYear

public java.lang.Double getEpsCurrentYear()
Returns:
the epsCurrentYear

getEpsNextQuarter

public java.lang.Double getEpsNextQuarter()
Returns:
the epsNextQuarter

getEpsNextYear

public java.lang.Double getEpsNextYear()
Returns:
the epsNextYear

getHighLimit

public java.lang.Double getHighLimit()
Returns:
the highLimit

getHoldingsGain

public java.lang.Double getHoldingsGain()
Returns:
the holdingsGain

getHoldingsGainMarket

public java.lang.Double getHoldingsGainMarket()
Returns:
the holdingsGainMarket

getHoldingValue

public java.lang.Double getHoldingValue()
Returns:
the holdingValue

getHoldingValueMarket

public java.lang.Double getHoldingValueMarket()
Returns:
the holdingValueMarket

getLastTrade

public java.lang.Double getLastTrade()
Returns:
the lastTrade

getLowLimit

public java.lang.Double getLowLimit()
Returns:
the lowLimit

getMarketCap

public java.lang.Double getMarketCap()
Returns:
the marketCap

getMarketCapMarket

public java.lang.Double getMarketCapMarket()
Returns:
the marketCapMarket

getOpen

public java.lang.Double getOpen()
Returns:
the open

getPegRatio

public java.lang.Double getPegRatio()
Returns:
the pegRatio

getPreviousClose

public java.lang.Double getPreviousClose()
Returns:
the previousClose

getPriceEarningRatio

public java.lang.Double getPriceEarningRatio()
Returns:
the priceEarningRatio

getPriceEarningRatioMarket

public java.lang.Double getPriceEarningRatioMarket()
Returns:
the priceEarningRatioMarket

getPricePaid

public java.lang.Double getPricePaid()
Returns:
the pricePaid

getPricePerBooks

public java.lang.Double getPricePerBooks()
Returns:
the pricePerBooks

getPricePerEPSCurrentYear

public java.lang.Double getPricePerEPSCurrentYear()
Returns:
the pricePerEPSCurrentYear

getPricePerEPSNextYear

public java.lang.Double getPricePerEPSNextYear()
Returns:
the pricePerEPSNextYear

getPricePerSales

public java.lang.Double getPricePerSales()
Returns:
the pricePerSales

getShortRatio

public java.lang.Double getShortRatio()
Returns:
the shortRatio

getTargetPriceOneYear

public java.lang.Double getTargetPriceOneYear()
Returns:
the targetPriceOneYear

getYearHigh

public java.lang.Double getYearHigh()
Returns:
the yearHigh

getYearHighChange

public java.lang.Double getYearHighChange()
Returns:
the yearHighChange

getYearLow

public java.lang.Double getYearLow()
Returns:
the yearLow

getYearLowChange

public java.lang.Double getYearLowChange()
Returns:
the yearLowChange

getBidSize

public java.lang.Long getBidSize()
Returns:
the bidSize

getLastTradeSize

public java.lang.Long getLastTradeSize()
Returns:
the lastTradeSize

getFloatShares

public java.lang.Long getFloatShares()
Returns:
the floatShares

getSharesOwned

public java.lang.Long getSharesOwned()
Returns:
the sharesOwned

getVolume

public java.lang.Long getVolume()
Returns:
the volume

getError

public java.lang.String getError()
Returns:
the error

getInfo

public java.lang.String getInfo()
Returns:
the info

getName

public java.lang.String getName()
Returns:
the name

getNotes

public java.lang.String getNotes()
Returns:
the notes

getOrderBook

public java.lang.String getOrderBook()
Returns:
the orderBook

getStockExchange

public java.lang.String getStockExchange()
Returns:
the stockExchange

getTicker

public java.lang.String getTicker()
Returns:
the ticker

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

main

public static void main(java.lang.String[] args)
                 throws java.net.MalformedURLException,
                        java.io.IOException
Print license.

Parameters:
args - ignored
Throws:
java.io.IOException
java.net.MalformedURLException