|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mov.quote.IDQuoteCache
public class IDQuoteCache
This class contains all the intra-day stock quotes currently in memory. Its purpose is to cache intra-day stock quotes so that tasks can share copies of the quotes rather than keep duplicate copies.
Tasks should not directly call this class, but should go through a IDQuoteBundle
.
When tasks access quotes in a quote cache, either directly or via a quote bundle they
can access quotes in two ways. The first way is specifying the actual time they
are interested in, i.e. a TradingTime
. The other way is specifying a fast
access time offset. The fast access time offset is used when lots of quotes have
to be queried as fast as possible.
The earliest time in the cache has an offset of 0. The next trading time has an
offset of 1, the next 2, etc. This is different from the EODQuoteCache
which
numbers the latest quote at 0. You can convert to and from fast access times
using timeToOffset(org.mov.util.TradingTime)
and offsetToTime(int)
.
IDQuote
,
IDQuoteBundle
Method Summary | |
---|---|
void |
addQuoteListener(QuoteListener quoteListener)
Add a listener to listen for new intra-day quotes. |
int |
getFirstTimeOffset()
Return the fast access time offset of the oldest time in the cache. |
static IDQuoteCache |
getInstance()
Create or return the singleton instance of the quote cache. |
int |
getLastTimeOffset()
Return the fast access time offset of the newest time in the cache. |
IDQuote |
getQuote(Symbol symbol,
int timeOffset)
Get a quote from the cache. |
double |
getQuote(Symbol symbol,
int quoteType,
int timeOffset)
Get a quote from the cache. |
void |
load(java.util.List quotes)
Load a time slice of intra-day quotes into the cache. |
TradingTime |
offsetToTime(int timeOffset)
Convert between a fast access time offset and a time. |
void |
removeQuoteListener(QuoteListener quoteListener)
Remove a listener for new intra-day quotes. |
int |
timeToOffset(TradingTime time)
Convert between a time and its fast access time offset. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static IDQuoteCache getInstance()
public double getQuote(Symbol symbol, int quoteType, int timeOffset) throws QuoteNotLoadedException
symbol
- the symbol to loadquoteType
- the quote type, one of Quote.DAY_OPEN
, Quote.DAY_CLOSE
,
Quote.DAY_LOW
, Quote.DAY_HIGH
, Quote.DAY_VOLUME
,
Quote.BID
, Quote.ASK
.timeOffset
- fast access time offset
QuoteNotLoadedException
- if the quote was not in the cachepublic IDQuote getQuote(Symbol symbol, int timeOffset) throws QuoteNotLoadedException
symbol
- the symbol to loadtimeOffset
- fast access time offset
QuoteNotLoadedException
- if the quote was not in the cachepublic void load(java.util.List quotes)
quotes
- list of quotes to cachepublic int timeToOffset(TradingTime time)
time
- the time
public TradingTime offsetToTime(int timeOffset)
null
if the
time is not in the cache.
timeOffset
- fast access time offset
public int getFirstTimeOffset()
public int getLastTimeOffset()
public void addQuoteListener(QuoteListener quoteListener)
quoteListener
- the class to be informed about new intra-day quotespublic void removeQuoteListener(QuoteListener quoteListener)
quoteListener
- the object to remove
|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |