Venice 0.751beta

nz.org.venice.analyser.gp
Class GPQuoteBundle

java.lang.Object
  extended bynz.org.venice.quote.EODQuoteBundle
      extended bynz.org.venice.analyser.gp.GPQuoteBundle
All Implemented Interfaces:
QuoteBundle

public class GPQuoteBundle
extends EODQuoteBundle

This class is a specialised version of the EODQuoteBundle tailored specifically for the GP. It differs from in that it enforces a window of dates. This window prevents the GP expressions from accessing quotes too far in the past which would slow down calculations (e.g. calculating the average value of a stock for the last 3,000 days), and also prevents GP expressions accessing quotes that would be in their future.

Author:
Andrew Leppard
See Also:
EODQuoteBundle

Field Summary
 
Fields inherited from class nz.org.venice.quote.EODQuoteBundle
quoteBundleCache, quoteCache
 
Constructor Summary
GPQuoteBundle(EODQuoteBundle quoteBundle, int window)
          Create a new quote bundle for the GP.
 
Method Summary
 double getQuote(Symbol symbol, int quoteType, int today, int offset)
          Get a stock quote.
 void setQuoteRange(EODQuoteRange quoteRange)
          Set the qutoe range which specifies this quote bundle.
 
Methods inherited from class nz.org.venice.quote.EODQuoteBundle
containsQuote, containsQuote, dateToOffset, getAllSymbols, getFirstDate, getFirstOffset, getFirstSymbol, getLastDate, getLastOffset, getNearestQuote, getOffset, getQuote, getQuote, getQuote, getQuoteRange, getSymbols, getSymbols, iterator, offsetToDate, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GPQuoteBundle

public GPQuoteBundle(EODQuoteBundle quoteBundle,
                     int window)
Create a new quote bundle for the GP.

Parameters:
quoteBundle - wrap the given quote bundle
window - prevent access to quotes this many days before the first quote in the given quote bundle
Method Detail

getQuote

public double getQuote(Symbol symbol,
                       int quoteType,
                       int today,
                       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 such as GPQuoteBundle can prevent the GP accessing 'future' dates.

Specified by:
getQuote in interface QuoteBundle
Overrides:
getQuote in class EODQuoteBundle
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
today - fast access date offset of current date, see EODQuoteCache
offset - offset from current date
Returns:
the quote
Throws:
EvaluationException - if the script isn't allowed access to the quote.
MissingQuoteException - if the quote was not found

setQuoteRange

public void setQuoteRange(EODQuoteRange quoteRange)
Set the qutoe range which specifies this quote bundle.

Overrides:
setQuoteRange in class EODQuoteBundle
Parameters:
quoteRange - the new quote range

Venice 0.751beta