|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mov.quote.EODQuoteBundle
public class EODQuoteBundle
When a task requires end-of-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 end-of-day quote cache -
EODQuoteCache
.
The purpose of this class is therefore to group together a set of quotes that are needed by a single task. This grouping allows the quotes to be loaded in at one time, which is much faster than loading them in quote by quote.
Also by placing a set of quotes in a bundle it simplifies caching. Caching is performed
by EODQuoteBundleCache
.
Example:
EODQuoteRange quoteRange = new QuoteRange("CBA"); EODQuoteBundle quoteBundle = new EODQuoteBundle(quoteRange); try { double = quoteBundle.getQuote("CBA", Quote.DAY_OPEN, 0); } catch(QuoteNotLoadedException e) { //... }
GPQuoteBundle
,
EODQuote
,
EODQuoteRange
,
EODQuoteBundleCache
,
EODQuoteCache
,
IDQuoteBundle
,
Symbol
Field Summary | |
---|---|
protected EODQuoteBundleCache |
quoteBundleCache
For speed reasons, keep reference to the global quote bundle cache |
protected EODQuoteCache |
quoteCache
For speed reasons, keep reference to the global quote cache |
Constructor Summary | |
---|---|
EODQuoteBundle(EODQuoteBundle quoteBundle)
Create a new end-of-day quote bundle with the same quote range as the given quote bundle. |
|
EODQuoteBundle(EODQuoteRange quoteRange)
Create a new end-of-day quote bundle that represents the quotes in the given quote range. |
Method Summary | |
---|---|
boolean |
containsQuote(Symbol symbol,
int dateOffset)
Return whether the given quote should be in this quote bundle. |
boolean |
containsQuote(Symbol symbol,
TradingDate date)
Return whether the given quote should be in this quote bundle. |
int |
dateToOffset(TradingDate date)
Convert between a date and a fast access date offset. |
java.util.List |
getAllSymbols()
Returns all the symbols in the quote bundle. |
TradingDate |
getFirstDate()
Return the first date in this quote bundle. |
int |
getFirstOffset()
Return the fast access date offset for the earliest quote in the bundle. |
Symbol |
getFirstSymbol()
Return the first symbol in the quote bundle. |
TradingDate |
getLastDate()
Return the last date in this quote bundle. |
int |
getLastOffset()
Return the fast access date 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 dateOffset)
Get a stock quote. |
double |
getQuote(Symbol symbol,
int quoteType,
int dateOffset)
Get a stock quote. |
double |
getQuote(Symbol symbol,
int quoteType,
int today,
int offset)
Get a stock quote. |
double |
getQuote(Symbol symbol,
int quoteType,
TradingDate date)
Get a stock quote. |
EODQuoteRange |
getQuoteRange()
Return the quote range which specifies this quote bundle. |
java.util.List |
getSymbols(int dateOffset)
Returns all the symbols listed in this quote bundle for the given date. |
java.util.List |
getSymbols(TradingDate date)
Returns all the symbols listed in this quote bundle for the given date. |
java.util.Iterator |
iterator()
Return an iterator over this quote bundle. |
TradingDate |
offsetToDate(int dateOffset)
Convert between a fast access date offset to an actual date. |
void |
setQuoteRange(EODQuoteRange quoteRange)
Set the qutoe range which specifies this quote bundle. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected EODQuoteCache quoteCache
protected EODQuoteBundleCache quoteBundleCache
Constructor Detail |
---|
public EODQuoteBundle(EODQuoteRange quoteRange)
quoteRange
- the quote rangepublic EODQuoteBundle(EODQuoteBundle quoteBundle)
quoteBundle
- the quote bundle to copyMethod Detail |
---|
public double getQuote(Symbol symbol, int quoteType, int dateOffset) throws MissingQuoteException
getQuote
in interface QuoteBundle
symbol
- the stock symbolquoteType
- the quote type, one of Quote.DAY_OPEN
, Quote.DAY_CLOSE
,
Quote.DAY_LOW
, Quote.DAY_HIGH
, Quote.DAY_VOLUME
dateOffset
- fast access date offset, see EODQuoteCache
MissingQuoteException
- if the quote was not foundpublic Quote getQuote(Symbol symbol, int dateOffset) throws MissingQuoteException
QuoteBundle
getQuote
in interface QuoteBundle
symbol
- the stock symboldateOffset
- 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
).
MissingQuoteException
- if the quote was not foundpublic double getQuote(Symbol symbol, int quoteType, int today, int offset) throws EvaluationException, MissingQuoteException
GPQuoteBundle
can prevent the GP
accessing 'future' dates.
getQuote
in interface QuoteBundle
symbol
- the stock symbolquoteType
- 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
EvaluationException
- if the script isn't allow access to the quote.
MissingQuoteException
- if the quote was not foundpublic double getQuote(Symbol symbol, int quoteType, TradingDate date) throws MissingQuoteException
symbol
- the stock symbolquoteType
- the quote type, one of Quote.DAY_OPEN
, Quote.DAY_CLOSE
,
Quote.DAY_LOW
, Quote.DAY_HIGH
, Quote.DAY_VOLUME
date
- the date
MissingQuoteException
- if the quote was not foundpublic boolean containsQuote(Symbol symbol, int dateOffset)
symbol
- the symboldateOffset
- fast access date offset, see EODQuoteCache
true
if this symbol should be in the quote bundle,
false
otherwisepublic boolean containsQuote(Symbol symbol, TradingDate date)
symbol
- the symboldate
- the date
true
if this symbol should be in the quote bundle,
false
otherwisepublic java.util.Iterator iterator()
Quote
public EODQuoteRange getQuoteRange()
public void setQuoteRange(EODQuoteRange quoteRange)
quoteRange
- the new quote rangepublic Symbol getFirstSymbol()
public java.util.List getAllSymbols()
public java.util.List getSymbols(int dateOffset)
dateOffset
- fast access date offset, see EODQuoteCache
public java.util.List getSymbols(TradingDate date)
date
- the date
public TradingDate getFirstDate()
public TradingDate getLastDate()
public int getFirstOffset()
getFirstOffset
in interface QuoteBundle
EODQuoteCache
public int getLastOffset()
getLastOffset
in interface QuoteBundle
EODQuoteCache
public TradingDate offsetToDate(int dateOffset)
offsetToDate
in interface QuoteBundle
dateOffset
- fast access date offset, see EODQuoteCache
public int dateToOffset(TradingDate date) throws WeekendDateException
date
- the date
EODQuoteCache
WeekendDateException
public int getOffset(Quote quote) throws WeekendDateException
getOffset
in interface QuoteBundle
quote
- quote
WeekendDateException
- if the date falls on a weekend.public java.lang.String toString()
toString
in class java.lang.Object
|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |