Venice 0.751beta

nz.org.venice.quote
Interface QuoteBundle

All Known Implementing Classes:
EODQuoteBundle, IDQuoteBundle, MixedQuoteBundle

public interface QuoteBundle

This class provides a generic interface which can be used to access a bundle of either end-of-day or intra-day quotes.

Author:
Andrew Leppard

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.
 double getNearestQuote(Symbol symbol, int quoteType, int offset)
          Get a stock quote nearest to the given offset.
 int getOffset(Quote quote)
          Return the fast access offset from the given quote.
 Quote getQuote(Symbol symbol, int offset)
          Get a stock quote.
 double getQuote(Symbol symbol, int quoteType, int offset)
          Get a stock quote.
 double getQuote(Symbol symbol, int quoteType, int now, int offset)
          Get a stock quote.
 TradingDate offsetToDate(int offset)
          Convert between a fast access offset to an actual date.
 

Method Detail

getQuote

public double getQuote(Symbol symbol,
                       int quoteType,
                       int now,
                       int offset)
                throws EvaluationException,
                       MissingQuoteException
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.

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).
offset - 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 offset)
                throws MissingQuoteException
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.

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
offset - 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

getNearestQuote

public double getNearestQuote(Symbol symbol,
                              int quoteType,
                              int offset)
                       throws MissingQuoteException
Get a stock quote nearest to the given offset.

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
offset - 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 offset)
               throws MissingQuoteException
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.

Parameters:
symbol - the stock symbol
offset - 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 offset)
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.

Parameters:
offset - fast access offset, see EODQuoteCache
Returns:
the date

getOffset

public int getOffset(Quote quote)
              throws WeekendDateException
Return the fast access offset from the given quote.

Parameters:
quote - quote
Returns:
fast access offset
Throws:
WeekendDateException

getFirstOffset

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

Returns:
fast access offset

getLastOffset

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

Returns:
fast access offset

Venice 0.751beta