Venice 0.751beta

nz.org.venice.quote
Class FileQuoteSource

java.lang.Object
  extended bynz.org.venice.quote.FileQuoteSource
All Implemented Interfaces:
QuoteSource

public class FileQuoteSource
extends java.lang.Object
implements QuoteSource

Provides functionality to obtain stock quotes from files. This class implements the QuoteSource interface to allow users to directly use their stock quote files without creating a database. Example:

      EODQuoteRange quoteRange = new EODQuoteRange("CBA");
      EODQuoteBundle quoteBundle = new EODQuoteBundle(quoteRange);
      try {
	    float = quoteBundle.getQuote("CBA", Quote.DAY_OPEN, 0);
      }
      catch(QuoteNotLoadedException e) {
          //...
      }
 

See Also:
Quote, EODQuoteRange, EODQuoteBundle

Constructor Summary
FileQuoteSource(java.lang.String format, java.util.List fileURLs)
          Creates a new quote source using the list of files specified in the user preferences.
 
Method Summary
 void cacheExpiry()
          Reset the first and last dates, forcing this quotesource to reload data from the filesystem.
 boolean containsDate(TradingDate date)
          Returns whether the source contains any quotes for the given date.
 int getAdvanceDecline(TradingDate date)
          Return the advance/decline for the given date.
 java.util.HashMap getAdvanceDecline(TradingDate firstDate, TradingDate lastDate)
          Return the advance/decline for the given date range.
 java.util.List getDates()
          Return all the dates which we have quotes for (SLOW0.
 java.util.List getExchangeRates(Currency sourceCurrency, Currency destinationCurrency)
          Return all the stored exchange rates between the two currencies.
 TradingDate getFirstDate()
          Return the earliest date we have any stock quotes for.
 TradingDate getLastDate()
          Return the latest date we have any stock quotes for.
 Symbol getSymbol(java.lang.String partialCompanyName)
          Returns the symbol associated with the given company.
 java.lang.String getSymbolName(Symbol symbol)
          Returns the company name associated with the given symbol.
 java.net.URL getURLForDate(TradingDate date)
          Returns the file URL that contains quotes for the given date.
 boolean isMarketIndex(Symbol symbol)
          Is the given symbol a market index?
 boolean loadQuoteRange(EODQuoteRange quoteRange)
          Load the given quote range into the quote cache.
 void shutdown()
          Shutdown the quote source.
 boolean symbolExists(Symbol symbol)
          Returns whether we have any quotes for the given symbol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileQuoteSource

public FileQuoteSource(java.lang.String format,
                       java.util.List fileURLs)
Creates a new quote source using the list of files specified in the user preferences.

Parameters:
format - The format filter to use to parse the quotes
fileURLs - List of URL of files
Method Detail

getSymbolName

public java.lang.String getSymbolName(Symbol symbol)
Returns the company name associated with the given symbol. Not implemented for the file quote source.

Specified by:
getSymbolName in interface QuoteSource
Parameters:
symbol - the stock symbol.
Returns:
always an empty string.

getSymbol

public Symbol getSymbol(java.lang.String partialCompanyName)
Returns the symbol associated with the given company. Not implemented for the file quote source.

Specified by:
getSymbol in interface QuoteSource
Parameters:
partialCompanyName - a partial company name.
Returns:
always an empty string.

symbolExists

public boolean symbolExists(Symbol symbol)
Returns whether we have any quotes for the given symbol.

Specified by:
symbolExists in interface QuoteSource
Parameters:
symbol - the symbol we are searching for.
Returns:
whether the symbol was found or not.

getFirstDate

public TradingDate getFirstDate()
Return the earliest date we have any stock quotes for.

Specified by:
getFirstDate in interface QuoteSource
Returns:
the oldest quote date

getLastDate

public TradingDate getLastDate()
Return the latest date we have any stock quotes for.

Specified by:
getLastDate in interface QuoteSource
Returns:
the most recent quote date.

getURLForDate

public java.net.URL getURLForDate(TradingDate date)
Returns the file URL that contains quotes for the given date.

Parameters:
date - the given date
Returns:
the file URL containing quotes for this date

containsDate

public boolean containsDate(TradingDate date)
Returns whether the source contains any quotes for the given date.

Specified by:
containsDate in interface QuoteSource
Parameters:
date - the date
Returns:
wehther the source contains the given date

getDates

public java.util.List getDates()
Return all the dates which we have quotes for (SLOW0.

Specified by:
getDates in interface QuoteSource
Returns:
a list of dates

loadQuoteRange

public boolean loadQuoteRange(EODQuoteRange quoteRange)
Load the given quote range into the quote cache.

Specified by:
loadQuoteRange in interface QuoteSource
Parameters:
quoteRange - the range of quotes to load
Returns:
TRUE if the operation suceeded
See Also:
EODQuote, EODQuoteCache

isMarketIndex

public boolean isMarketIndex(Symbol symbol)
Is the given symbol a market index?

Specified by:
isMarketIndex in interface QuoteSource
Parameters:
symbol - to test
Returns:
yes or no

getAdvanceDecline

public int getAdvanceDecline(TradingDate date)
                      throws MissingQuoteException
Return the advance/decline for the given date. This returns the number of all ordinary stocks that rose (day close > day open) - the number of all ordinary stocks that fell.

Specified by:
getAdvanceDecline in interface QuoteSource
Parameters:
date - the date
Returns:
the difference between the number of advances and declines for date
Throws:
throws - MissingQuoteException if the date wasn't in the source
MissingQuoteException

getAdvanceDecline

public java.util.HashMap getAdvanceDecline(TradingDate firstDate,
                                           TradingDate lastDate)
                                    throws MissingQuoteException
Description copied from interface: QuoteSource
Return the advance/decline for the given date range. This returns the number of all ordinary stocks that rose (day close > day open) - the number of all ordinary stocks that fell.

Specified by:
getAdvanceDecline in interface QuoteSource
Parameters:
firstDate - the start of the inclusive date range
lastDate - the end of the inclusive date range
Returns:
A map of dates and advance/decline differences for each date in the range
Throws:
MissingQuoteException

getExchangeRates

public java.util.List getExchangeRates(Currency sourceCurrency,
                                       Currency destinationCurrency)
Return all the stored exchange rates between the two currencies.

Specified by:
getExchangeRates in interface QuoteSource
Parameters:
sourceCurrency - the currency to convert from
destinationCurrency - the currency to convert to
Returns:
the exchange rate being the number of destinationCurrency that you can buy per sourceCurrency

shutdown

public void shutdown()
Description copied from interface: QuoteSource
Shutdown the quote source.

Specified by:
shutdown in interface QuoteSource

cacheExpiry

public void cacheExpiry()
Reset the first and last dates, forcing this quotesource to reload data from the filesystem.

Specified by:
cacheExpiry in interface QuoteSource

Venice 0.751beta