Class Stock
- java.lang.Object
-
- yahoofinance.Stock
-
public class Stock extends java.lang.Object- Author:
- Stijn Strickx
-
-
Constructor Summary
Constructors Constructor Description Stock(java.lang.String symbol)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetCurrency()Get the currency of the stockStockDividendgetDividend()Returns the dividend data available for this stock.StockDividendgetDividend(boolean refresh)Returns the dividend data available for this stock.java.util.List<HistoricalDividend>getDividendHistory()This method will return historical dividends from this stock.java.util.List<HistoricalDividend>getDividendHistory(java.util.Calendar from)Requests the historical dividends for this stock with the following characteristics.java.util.List<HistoricalDividend>getDividendHistory(java.util.Calendar from, java.util.Calendar to)Requests the historical dividends for this stock with the following characteristics.java.util.List<HistoricalQuote>getHistory()This method will return historical quotes from this stock.java.util.List<HistoricalQuote>getHistory(java.util.Calendar from)Requests the historical quotes for this stock with the following characteristics.java.util.List<HistoricalQuote>getHistory(java.util.Calendar from, java.util.Calendar to)Requests the historical quotes for this stock with the following characteristics.java.util.List<HistoricalQuote>getHistory(java.util.Calendar from, java.util.Calendar to, Interval interval)Requests the historical quotes for this stock with the following characteristics.java.util.List<HistoricalQuote>getHistory(java.util.Calendar from, Interval interval)Requests the historical quotes for this stock with the following characteristics.java.util.List<HistoricalQuote>getHistory(Interval interval)Requests the historical quotes for this stock with the following characteristics.java.lang.StringgetName()Get the full name of the stockStockQuotegetQuote()Returns the basic quotes data available for this stock.StockQuotegetQuote(boolean refresh)Returns the basic quotes data available for this stock.java.util.List<HistoricalSplit>getSplitHistory()This method will return historical splits from this stock.java.util.List<HistoricalSplit>getSplitHistory(java.util.Calendar from)Requests the historical splits for this stock with the following characteristics.java.util.List<HistoricalSplit>getSplitHistory(java.util.Calendar from, java.util.Calendar to)Requests the historical splits for this stock with the following characteristics.StockStatsgetStats()Returns the statistics available for this stock.StockStatsgetStats(boolean refresh)Returns the statistics available for this stock.java.lang.StringgetStockExchange()Get the exchange on which the stock is tradedjava.lang.StringgetSymbol()booleanisValid()Checks if the returned name is null.voidprint()voidsetCurrency(java.lang.String currency)voidsetDividend(StockDividend dividend)voidsetDividendHistory(java.util.List<HistoricalDividend> dividendHistory)voidsetHistory(java.util.List<HistoricalQuote> history)voidsetName(java.lang.String name)voidsetQuote(StockQuote quote)voidsetSplitHistory(java.util.List<HistoricalSplit> splitHistory)voidsetStats(StockStats stats)voidsetStockExchange(java.lang.String stockExchange)java.lang.StringtoString()
-
-
-
Method Detail
-
isValid
public boolean isValid()
Checks if the returned name is null. This probably means that the symbol was not recognized by Yahoo Finance.- Returns:
- whether this stock's symbol is known by Yahoo Finance (true) or not (false)
-
getQuote
public StockQuote getQuote()
Returns the basic quotes data available for this stock.- Returns:
- basic quotes data available for this stock
- See Also:
getQuote(boolean)
-
getQuote
public StockQuote getQuote(boolean refresh) throws java.io.IOException
Returns the basic quotes data available for this stock. This method will return null in the following situations:- the data hasn't been loaded yet in a previous request and refresh is set to false.
- refresh is true and the data cannot be retrieved from Yahoo Finance for whatever reason (symbol not recognized, no network connection, ...)
When the quote data gets refreshed, it will automatically also refresh the statistics and dividend data of the stock from Yahoo Finance in the same request.
- Parameters:
refresh- indicates whether the data should be requested again to Yahoo Finance- Returns:
- basic quotes data available for this stock
- Throws:
java.io.IOException- when there's a connection problem
-
setQuote
public void setQuote(StockQuote quote)
-
getStats
public StockStats getStats()
Returns the statistics available for this stock.- Returns:
- statistics available for this stock
- See Also:
getStats(boolean)
-
getStats
public StockStats getStats(boolean refresh) throws java.io.IOException
Returns the statistics available for this stock. This method will return null in the following situations:- the data hasn't been loaded yet in a previous request and refresh is set to false.
- refresh is true and the data cannot be retrieved from Yahoo Finance for whatever reason (symbol not recognized, no network connection, ...)
When the statistics get refreshed, it will automatically also refresh the quote and dividend data of the stock from Yahoo Finance in the same request.
- Parameters:
refresh- indicates whether the data should be requested again to Yahoo Finance- Returns:
- statistics available for this stock
- Throws:
java.io.IOException- when there's a connection problem
-
setStats
public void setStats(StockStats stats)
-
getDividend
public StockDividend getDividend()
Returns the dividend data available for this stock.- Returns:
- dividend data available for this stock
- See Also:
getDividend(boolean)
-
getDividend
public StockDividend getDividend(boolean refresh) throws java.io.IOException
Returns the dividend data available for this stock. This method will return null in the following situations:- the data hasn't been loaded yet in a previous request and refresh is set to false.
- refresh is true and the data cannot be retrieved from Yahoo Finance for whatever reason (symbol not recognized, no network connection, ...)
When the dividend data get refreshed, it will automatically also refresh the quote and statistics data of the stock from Yahoo Finance in the same request.
- Parameters:
refresh- indicates whether the data should be requested again to Yahoo Finance- Returns:
- dividend data available for this stock
- Throws:
java.io.IOException- when there's a connection problem
-
setDividend
public void setDividend(StockDividend dividend)
-
getHistory
public java.util.List<HistoricalQuote> getHistory() throws java.io.IOException
This method will return historical quotes from this stock. If the historical quotes are not available yet, they will be requested first from Yahoo Finance.If the historical quotes are not available yet, the following characteristics will be used for the request:
- from: 1 year ago (default)
- to: today (default)
- interval: MONTHLY (default)
There are several more methods available that allow you to define some characteristics of the historical data. Calling one of those methods will result in a new request being sent to Yahoo Finance.
- Returns:
- a list of historical quotes from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getHistory(yahoofinance.histquotes.Interval),getHistory(java.util.Calendar),getHistory(java.util.Calendar, java.util.Calendar),getHistory(java.util.Calendar, yahoofinance.histquotes.Interval),getHistory(java.util.Calendar, java.util.Calendar, yahoofinance.histquotes.Interval)
-
getHistory
public java.util.List<HistoricalQuote> getHistory(Interval interval) throws java.io.IOException
Requests the historical quotes for this stock with the following characteristics.- from: 1 year ago (default)
- to: today (default)
- interval: specified value
- Parameters:
interval- the interval of the historical data- Returns:
- a list of historical quotes from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getHistory()
-
getHistory
public java.util.List<HistoricalQuote> getHistory(java.util.Calendar from) throws java.io.IOException
Requests the historical quotes for this stock with the following characteristics.- from: specified value
- to: today (default)
- interval: MONTHLY (default)
- Parameters:
from- start date of the historical data- Returns:
- a list of historical quotes from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getHistory()
-
getHistory
public java.util.List<HistoricalQuote> getHistory(java.util.Calendar from, Interval interval) throws java.io.IOException
Requests the historical quotes for this stock with the following characteristics.- from: specified value
- to: today (default)
- interval: specified value
- Parameters:
from- start date of the historical datainterval- the interval of the historical data- Returns:
- a list of historical quotes from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getHistory()
-
getHistory
public java.util.List<HistoricalQuote> getHistory(java.util.Calendar from, java.util.Calendar to) throws java.io.IOException
Requests the historical quotes for this stock with the following characteristics.- from: specified value
- to: specified value
- interval: MONTHLY (default)
- Parameters:
from- start date of the historical datato- end date of the historical data- Returns:
- a list of historical quotes from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getHistory()
-
getHistory
public java.util.List<HistoricalQuote> getHistory(java.util.Calendar from, java.util.Calendar to, Interval interval) throws java.io.IOException
Requests the historical quotes for this stock with the following characteristics.- from: specified value
- to: specified value
- interval: specified value
- Parameters:
from- start date of the historical datato- end date of the historical datainterval- the interval of the historical data- Returns:
- a list of historical quotes from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getHistory()
-
setHistory
public void setHistory(java.util.List<HistoricalQuote> history)
-
getDividendHistory
public java.util.List<HistoricalDividend> getDividendHistory() throws java.io.IOException
This method will return historical dividends from this stock. If the historical dividends are not available yet, they will be requested first from Yahoo Finance.If the historical dividends are not available yet, the following characteristics will be used for the request:
- from: 1 year ago (default)
- to: today (default)
There are several more methods available that allow you to define some characteristics of the historical data. Calling one of those methods will result in a new request being sent to Yahoo Finance.
- Returns:
- a list of historical dividends from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getDividendHistory(java.util.Calendar),getDividendHistory(java.util.Calendar, java.util.Calendar)
-
getDividendHistory
public java.util.List<HistoricalDividend> getDividendHistory(java.util.Calendar from) throws java.io.IOException
Requests the historical dividends for this stock with the following characteristics.- from: specified value
- to: today (default)
- Parameters:
from- start date of the historical data- Returns:
- a list of historical dividends from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getDividendHistory()
-
getDividendHistory
public java.util.List<HistoricalDividend> getDividendHistory(java.util.Calendar from, java.util.Calendar to) throws java.io.IOException
Requests the historical dividends for this stock with the following characteristics.- from: specified value
- to: specified value
- Parameters:
from- start date of the historical datato- end date of the historical data- Returns:
- a list of historical dividends from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getDividendHistory()
-
setDividendHistory
public void setDividendHistory(java.util.List<HistoricalDividend> dividendHistory)
-
getSplitHistory
public java.util.List<HistoricalSplit> getSplitHistory() throws java.io.IOException
This method will return historical splits from this stock. If the historical splits are not available yet, they will be requested first from Yahoo Finance.If the historical splits are not available yet, the following characteristics will be used for the request:
- from: 1 year ago (default)
- to: today (default)
There are several more methods available that allow you to define some characteristics of the historical data. Calling one of those methods will result in a new request being sent to Yahoo Finance.
- Returns:
- a list of historical splits from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getSplitHistory(java.util.Calendar),getSplitHistory(java.util.Calendar, java.util.Calendar)
-
getSplitHistory
public java.util.List<HistoricalSplit> getSplitHistory(java.util.Calendar from) throws java.io.IOException
Requests the historical splits for this stock with the following characteristics.- from: specified value
- to: today (default)
- Parameters:
from- start date of the historical data- Returns:
- a list of historical splits from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getSplitHistory()
-
getSplitHistory
public java.util.List<HistoricalSplit> getSplitHistory(java.util.Calendar from, java.util.Calendar to) throws java.io.IOException
Requests the historical splits for this stock with the following characteristics.- from: specified value
- to: specified value
- Parameters:
from- start date of the historical datato- end date of the historical data- Returns:
- a list of historical splits from this stock
- Throws:
java.io.IOException- when there's a connection problem- See Also:
getSplitHistory()
-
setSplitHistory
public void setSplitHistory(java.util.List<HistoricalSplit> splitHistory)
-
getSymbol
public java.lang.String getSymbol()
-
getName
public java.lang.String getName()
Get the full name of the stock- Returns:
- the name or null if the data is not available
-
setName
public void setName(java.lang.String name)
-
getCurrency
public java.lang.String getCurrency()
Get the currency of the stock- Returns:
- the currency or null if the data is not available
-
setCurrency
public void setCurrency(java.lang.String currency)
-
getStockExchange
public java.lang.String getStockExchange()
Get the exchange on which the stock is traded- Returns:
- the exchange or null if the data is not available
-
setStockExchange
public void setStockExchange(java.lang.String stockExchange)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
print
public void print()
-
-