Venice 0.7beta

org.mov.quote
Class IDQuoteBundle

java.lang.Object
  extended by org.mov.quote.IDQuoteBundle
All Implemented Interfaces:
QuoteBundle

public class IDQuoteBundle
extends java.lang.Object
implements QuoteBundle

When a task requires intra-day stock quotes, it should create an instance of this class which represents all the task's required quotes. The task can then access quotes from this class, which in turn reads its stock quotes from the global intra-day quote cache - IDQuoteCache. To be notified of new intra-day quotes call IDQuoteCache.addQuoteListener(org.mov.quote.QuoteListener).

Example:

      IDQuoteBundle quoteBundle = new IDQuoteBundle("CBA");
      try {
            double = quoteBundle.getQuote("CBA", Quote.ASK, 0);
      }
      catch(QuoteNotLoadedException e) {
          //...
      }
 

Author:
Andrew Leppard
See Also:
IDQuote, IDQuoteCache, EODQuoteBundle, Symbol

Constructor Summary
IDQuoteBundle(java.util.List symbols)
          Create a new intra-day quote bundle containing all today's quotes for the given symbols.
 
Method Summary
 int getFirstOffset()
          Return the fast access offset for the earliest quote in the bundle.
 int getLastOffset()
          Return the fast access offset for the latest quote in the bundle.
 int getOffset(Quote quote)
          Retrieve the fast access offset from the given quote.
 Quote getQuote(Symbol symbol, int timeOffset)
          Get a stock quote.
 double getQuote(Symbol symbol, int quoteType, int timeOffset)
          Get a stock quote.
 double getQuote(Symbol symbol, int quoteType, int now, int timeOffset)
          Get a stock quote.
 TradingDate offsetToDate(int timeOffset)
          Convert between a fast access offset to an actual date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IDQuoteBundle

public IDQuoteBundle(java.util.List symbols)
Create a new intra-day quote bundle containing all today's quotes for the given symbols.

Parameters:
symbols - the quote symbols
Method Detail

getQuote

public double getQuote(Symbol symbol,
                       int quoteType,
                       int now,
                       int timeOffset)
                throws EvaluationException,
                       MissingQuoteException
Description copied from interface: QuoteBundle
Get a stock quote. This function has been primarily created for Gondola scripts. It passes in the current date and the date offset so that specialised QuoteBundle implementations can prevent the GP accessing 'future' dates.

Specified by:
getQuote in interface QuoteBundle
Parameters:
symbol - the stock symbol
quoteType - the quote type, e.g. Quote.DAY_OPEN, Quote.DAY_CLOSE, Quote.DAY_LOW, Quote.DAY_HIGH, Quote.DAY_VOLUME
now - fast access offset of current quote, for end-of-day quotes this is the fast access date offset (see EODQuoteCache). For intra-day quotes, it is the fast access time offset (see IDQuoteCache).
timeOffset - modifier offset to fast access offset
Returns:
the quote
Throws:
EvaluationException - if the script isn't allow access to the quote.
MissingQuoteException - if the quote was not found

getQuote

public double getQuote(Symbol symbol,
                       int quoteType,
                       int timeOffset)
                throws MissingQuoteException
Description copied from interface: QuoteBundle
Get a stock quote. If the stock is earlier than the first date in the bundle, the bundle will be expand to include the new date given. If the stock symbol is not included in the original symbol list, the quote bundle will be expanded to include it.

Specified by:
getQuote in interface QuoteBundle
Parameters:
symbol - the stock symbol
quoteType - the quote type, one of Quote.DAY_OPEN, Quote.DAY_CLOSE, Quote.DAY_LOW, Quote.DAY_HIGH, Quote.DAY_VOLUME
timeOffset - fast access offset of current quote, for end-of-day quotes this is the fast access date offset (see EODQuoteCache). For intra-day quotes, it is the fast access time offset (see IDQuoteCache).
Returns:
the quote
Throws:
MissingQuoteException - if the quote was not found

getQuote

public Quote getQuote(Symbol symbol,
                      int timeOffset)
               throws MissingQuoteException
Description copied from interface: QuoteBundle
Get a stock quote. If the stock is earlier than the first date in the bundle, the bundle will be expand to include the new date given. If the stock symbol is not included in the original symbol list, the quote bundle will be expanded to include it.

Specified by:
getQuote in interface QuoteBundle
Parameters:
symbol - the stock symbol
timeOffset - fast access offset of current quote, for end-of-day quotes this is the fast access date offset (see EODQuoteCache). For intra-day quotes, it is the fast access time offset (see IDQuoteCache).
Returns:
the quote
Throws:
MissingQuoteException - if the quote was not found

offsetToDate

public TradingDate offsetToDate(int timeOffset)
Description copied from interface: QuoteBundle
Convert between a fast access offset to an actual date. Intra-day quotes will return the same date for each offset because the offset refers to the time within that date. End-of-day quotes will return a different date for each fast access offset.

Specified by:
offsetToDate in interface QuoteBundle
Parameters:
timeOffset - fast access offset, see EODQuoteCache
Returns:
the date

getOffset

public int getOffset(Quote quote)
Retrieve the fast access offset from the given quote.

Specified by:
getOffset in interface QuoteBundle
Parameters:
quote - quote
Returns:
fast access offset

getFirstOffset

public int getFirstOffset()
Return the fast access offset for the earliest quote in the bundle.

Specified by:
getFirstOffset in interface QuoteBundle
Returns:
fast access offset

getLastOffset

public int getLastOffset()
Return the fast access offset for the latest quote in the bundle.

Specified by:
getLastOffset in interface QuoteBundle
Returns:
fast access offset

Venice 0.7beta