Venice 0.751beta
Class GraphableQuoteFunctionSource

All Implemented Interfaces:

public class GraphableQuoteFunctionSource
extends java.lang.Object
implements QuoteFunctionSource

Allow the QuoteFunctions package to use quotes directly from a Graphable. The following code, from MovingAverageGraph shows an example of how to call a quote function from a graph:

      Graphable movingAverage = new Graphable();
      TradingDate date = (TradingDate)source.getStartX();
      GraphableQuoteFunctionSource quoteFunctionSource 
          = new GraphableQuoteFunctionSource(source, date, period);

      for(Iterator iterator = source.iterator(); iterator.hasNext();) {
          date = (TradingDate);

          try {
              double average = QuoteFunctions.avg(quoteFunctionSource, period);
              movingAverage.putY(date, new Double(average));
          catch(EvaluationException e) {

Andrew Leppard
See Also:

Constructor Summary
GraphableQuoteFunctionSource(Graphable graphable, TradingDate date, int period)
          Create a new quote function source that uses quotes directly from a Graphable.
Method Summary
 double getValue(int index)
          Return the quote value on the given date.
 void setDate(TradingDate date)
          Set the current date.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public GraphableQuoteFunctionSource(Graphable graphable,
                                    TradingDate date,
                                    int period)
Create a new quote function source that uses quotes directly from a Graphable.

graphable - the graphable containing the quotes
date - the current date, the previous quotes for period number of days will be accessed
period - the number of quote dates available from this source
Method Detail


public void setDate(TradingDate date)
Set the current date. Since quote functions use previous day's quote values, this function source will provide the previous quotes for period number of days. The date given here will be the most recent quote date available from the source.

date - the current date


public double getValue(int index)
                throws EvaluationException
Description copied from interface: QuoteFunctionSource
Return the quote value on the given date. The quote function source contains a set of quotes which can be accessed from offset 0, which is the earliest date, to the number of quotes in the source minus one. Typically a quote source is set up to contain a fixed number of quotes, each of which is used by a quote function.

Specified by:
getValue in interface QuoteFunctionSource
index - the offset of the date in the quote source.
the quote value or NaN if the quote is missing / not available
EvaluationException - if QuoteBundleFunctionSource is not allowed access to a quote. See GPQuoteBundle.

Venice 0.751beta