Venice 0.7beta

org.mov.quote
Class EODQuoteRange

java.lang.Object
  extended by org.mov.quote.EODQuoteRange
All Implemented Interfaces:
java.lang.Cloneable

public class EODQuoteRange
extends java.lang.Object
implements java.lang.Cloneable

This class represents a way of describing a range or a set of end-of-day quotes. A range of quotes will consist of a set of symbols that we are interested in. This can be described by either explicitly giving a set of symbols, e.g. ANZ, CBA, NBA, WBC. Or by specifying the type of symbols we are intersted in, e.g. all ordinaries, all symbols, market indices etc.

The quote range is also limited by a date range.

For example this class could represent all CBA quotes from 1/12/2000 to 12/12/2000, or all market indices.

A quote range represents a range or set of quotes. It does not represent the actual quotes themselves. The class that represents the quotes in a quote range is QuoteBundle.


Field Summary
static int ALL_ORDINARIES
          Represents all 3 letter symbols, not included market indices
static int ALL_SYMBOLS
          Represents all symbols
static int GIVEN_SYMBOLS
          Represents an explicit list of symbols
static int MARKET_INDICES
          Represents market indices
 
Constructor Summary
EODQuoteRange(int type)
          Create a quote range that represents all the symbols of the given type for all the dates we have quotes.
EODQuoteRange(int type, TradingDate date)
          Create a quote range that represents all the symbols of the given type on the given date.
EODQuoteRange(int type, TradingDate firstDate, TradingDate lastDate)
          Create a quote range that represents all the symbols of the given type between the first and the last dates given (inclusive).
EODQuoteRange(java.util.List symbols)
          Create a quote range that represents all the given symbols for all the dates we have quotes.
EODQuoteRange(java.util.List symbols, TradingDate date)
          Create a quote range that represents all the given symbols on the given date.
EODQuoteRange(java.util.List symbols, TradingDate firstDate, TradingDate lastDate)
          Create a quote range that represents all the given symbols between the first and the last dates given (inclusive).
EODQuoteRange(java.util.SortedSet symbols)
          Create a quote range that represents all the given symbols for all the dates we have quotes.
EODQuoteRange(Symbol symbol)
          Create a quote range that represents the given symbol for all the dates we have quotes.
EODQuoteRange(Symbol symbol, TradingDate firstDate, TradingDate lastDate)
          Create a quote range that represents the given symbol between the first and the last dates given (inclusive).
 
Method Summary
 void addSymbol(Symbol symbol)
          Expand the quote range to include a new symbol.
 EODQuoteRange clip(EODQuoteRange quoteRange)
          Return a new clipped quote range that, if possible, does not overlap with this quote range.
 java.lang.Object clone()
          Create a clone of this quote range.
 boolean containsAllSymbols(java.util.List containedSymbols)
          Returns whether the quote range contains all the given symbols.
 boolean containsSymbol(Symbol symbol)
          Returns whether the quote range contains the given symbol.
 java.util.List getAllSymbols()
          Return all the symbols in the quote range.
 java.lang.String getDescription()
          Creates a string representation of the quote range without referring to the dates.
static java.lang.String getDescription(int type)
          Creates a string representation of the given quote range type.
 TradingDate getFirstDate()
          Get the first date of the quote range.
 TradingDate getLastDate()
          Get the last date of the quote range.
 int getType()
          Get the type of the quote range.
 boolean isEmpty()
          Return whether this quote range includes any quotes.
 void setFirstDate(TradingDate firstDate)
          Set the first date of the quote range.
 void setLastDate(TradingDate lastDate)
          Set the last date of the quote range.
 java.lang.String toString()
          Create a string representation of the quote range.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL_ORDINARIES

public static final int ALL_ORDINARIES
Represents all 3 letter symbols, not included market indices

See Also:
Constant Field Values

ALL_SYMBOLS

public static final int ALL_SYMBOLS
Represents all symbols

See Also:
Constant Field Values

MARKET_INDICES

public static final int MARKET_INDICES
Represents market indices

See Also:
Constant Field Values

GIVEN_SYMBOLS

public static final int GIVEN_SYMBOLS
Represents an explicit list of symbols

See Also:
Constant Field Values
Constructor Detail

EODQuoteRange

public EODQuoteRange(java.util.List symbols)
Create a quote range that represents all the given symbols for all the dates we have quotes.

Parameters:
symbols - list of symbols

EODQuoteRange

public EODQuoteRange(java.util.SortedSet symbols)
Create a quote range that represents all the given symbols for all the dates we have quotes.

Parameters:
symbols - list of symbols

EODQuoteRange

public EODQuoteRange(java.util.List symbols,
                     TradingDate firstDate,
                     TradingDate lastDate)
Create a quote range that represents all the given symbols between the first and the last dates given (inclusive).

Parameters:
symbols - list of symbols
firstDate - earliest date
lastDate - latest date

EODQuoteRange

public EODQuoteRange(java.util.List symbols,
                     TradingDate date)
Create a quote range that represents all the given symbols on the given date.

Parameters:
symbols - list of symbols
date - the date

EODQuoteRange

public EODQuoteRange(Symbol symbol)
Create a quote range that represents the given symbol for all the dates we have quotes.

Parameters:
symbol - the symbol

EODQuoteRange

public EODQuoteRange(Symbol symbol,
                     TradingDate firstDate,
                     TradingDate lastDate)
Create a quote range that represents the given symbol between the first and the last dates given (inclusive).

Parameters:
symbol - the symbol
firstDate - earliest date
lastDate - latest date

EODQuoteRange

public EODQuoteRange(int type,
                     TradingDate date)
Create a quote range that represents all the symbols of the given type on the given date.

Parameters:
type - the type, one of ALL_ORDINARIES, ALL_SYMBOLS, MARKET_INDICES
date - the date

EODQuoteRange

public EODQuoteRange(int type,
                     TradingDate firstDate,
                     TradingDate lastDate)
Create a quote range that represents all the symbols of the given type between the first and the last dates given (inclusive).

Parameters:
type - the type, one of ALL_ORDINARIES, ALL_SYMBOLS, MARKET_INDICES
firstDate - earliest date
lastDate - latest date

EODQuoteRange

public EODQuoteRange(int type)
Create a quote range that represents all the symbols of the given type for all the dates we have quotes. This might use up a lot of memory!

Parameters:
type - the type, one of ALL_ORDINARIES, ALL_SYMBOLS, MARKET_INDICES
Method Detail

clone

public java.lang.Object clone()
Create a clone of this quote range.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this quote range

getAllSymbols

public java.util.List getAllSymbols()
Return all the symbols in the quote range. This function is only valid for quote ranges that have explicitly given a set of symbols.

Returns:
a list of symbols

setFirstDate

public void setFirstDate(TradingDate firstDate)
Set the first date of the quote range.

Parameters:
firstDate - earliest date

setLastDate

public void setLastDate(TradingDate lastDate)
Set the last date of the quote range.

Parameters:
lastDate - latest date

getFirstDate

public TradingDate getFirstDate()
Get the first date of the quote range.

Returns:
the earliest date of the quote range, null indicates that the quote range encompasses all available dates

getLastDate

public TradingDate getLastDate()
Get the last date of the quote range.

Returns:
the latest date of the quote range, null indicates that the quote range encompasses all available dates

isEmpty

public boolean isEmpty()
Return whether this quote range includes any quotes. This function checks for a null quote range, not an empty quote cache.

Returns:
true if this quote range covers an empty range, false otherwise.

getType

public int getType()
Get the type of the quote range.

Returns:
one of ALL_ORDINARIES, ALL_SYMBOLS, MARKET_INDICES, GIVEN_SYMBOLS

containsSymbol

public boolean containsSymbol(Symbol symbol)
Returns whether the quote range contains the given symbol.

Parameters:
symbol - the symbol
Returns:
true if the symbol is in the quote range, false otherwise

addSymbol

public void addSymbol(Symbol symbol)
Expand the quote range to include a new symbol. This function is only valid for quote ranges that have explicitly given a set of symbols.

Parameters:
symbol - new symbol

containsAllSymbols

public boolean containsAllSymbols(java.util.List containedSymbols)
Returns whether the quote range contains all the given symbols.

Parameters:
containedSymbols - all the symbols to check for
Returns:
true if all the symbols are in the quote range, false otherwise

getDescription

public java.lang.String getDescription()
Creates a string representation of the quote range without referring to the dates.

Returns:
string representation, e.g. "All Ordinaries"

getDescription

public static java.lang.String getDescription(int type)
Creates a string representation of the given quote range type.

Parameters:
type - the type, one of ALL_ORDINARIES, ALL_SYMBOLS, MARKET_INDICES or GIVEN_SYMBOLS
Returns:
string representation, e.g. "All Ordinaries"

toString

public java.lang.String toString()
Create a string representation of the quote range. This is for debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
string representation

clip

public EODQuoteRange clip(EODQuoteRange quoteRange)
Return a new clipped quote range that, if possible, does not overlap with this quote range. The idea behind this function is that when we need to load in quotes specified from a quote range, we want to check with all the currently loaded quote ranges to see if some of the quotes have already been loaded.

e.g.

 EODQuoteRange quoteRange = new EODQuoteRange("CBA", new TradingDate(2000, 1, 1),
                                              new TradingDate(2000, 12, 1));
 EODQuoteRange quoteRange2 = new EODQuoteRange("CBA", new TradingDate(1999, 1, 1),
                                               new TradingDate(2000, 6, 6));
 EODQuoteRange clippedQuoteRange = quoteRange.clipRange(quoteRange2);

 System.out.println(clippedQuoteRange);

 >> cba between 1-1-1999 and 31-12-1999

 

Parameters:
quoteRange - quote range to clip
Returns:
the clipped quote range

Venice 0.7beta