|
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.EODQuoteCache
public class EODQuoteCache
This class contains all the end-of-day stock quotes currently in memory. Its purpose is to
cache end-of-day stock quotes so that tasks do not have to query the database or files
whenever they need a quote. While this is a cache it does not control when stock quotes are
loaded or freed, that is controlled by EODQuoteBundleCache
.
Tasks should not directly call this class, but should go through a EODQuoteBundle
.
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 date they
are interested in, i.e. a TradingDate
. The other way is specifying a fast
access date offset. The fast access date offset is used when lots of quotes have
to be queried as fast as possible.
The latest date in the cache has an offset of 0. The previous trading date
(i.e. not a weekend) has offset -1, the previous one to that -2 etc.
You can convert to and from fast access dates using dateToOffset(org.mov.util.TradingDate)
and
offsetToDate(int)
.
EODQuote
,
EODQuoteBundle
,
EODQuoteBundleCache
Method Summary | |
---|---|
boolean |
containsQuote(Symbol symbol,
int dateOffset)
Return whether we currently have any quotes for the given symbol on the given date |
int |
dateToOffset(TradingDate date)
Convert between a date and its fast access date offset. |
void |
free(Symbol symbol,
int dateOffset)
Remove the given quote from the cache. |
TradingDate |
getFirstDate()
Get the oldest date in the cache. |
int |
getFirstDateOffset()
Get the fast access offset of the oldest date in the cache. |
static EODQuoteCache |
getInstance()
Create or return the singleton instance of the quote cache. |
TradingDate |
getLastDate()
Get the newest date in the cache. |
EODQuote |
getQuote(Symbol symbol,
int dateOffset)
Get a quote from the cache. |
double |
getQuote(Symbol symbol,
int quoteType,
int dateOffset)
Get a quote from the cache. |
java.util.List |
getSymbols(int dateOffset)
Return all the symbols in the cache on the given date. |
java.util.List |
getSymbols(int firstDateOffset,
int lastDateOffset)
Return all the symbols in the cache between the given date range (inclusive). |
static boolean |
isInstantiated()
Returns whether this class has been instantiated yet. |
void |
load(EODQuote quote)
Load the given quote into the cache. |
void |
load(Symbol symbol,
TradingDate date,
int day_volume,
float day_low,
float day_high,
float day_open,
float day_close)
Load the given quote into the cache. |
TradingDate |
offsetToDate(int dateOffset)
Convert between a fast access date offset and a date. |
int |
size()
Return the number of quotes in the cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static EODQuoteCache getInstance()
public static boolean isInstantiated()
true
if this class has been instantiated.public double getQuote(Symbol symbol, int quoteType, int dateOffset) 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
dateOffset
- fast access date offset
QuoteNotLoadedException
- if the quote was not in the cachepublic EODQuote getQuote(Symbol symbol, int dateOffset) throws QuoteNotLoadedException
symbol
- the symbol to loaddateOffset
- fast access date offset
QuoteNotLoadedException
- if the quote was not in the cachepublic java.util.List getSymbols(int dateOffset)
dateOffset
- fast access date offset
public java.util.List getSymbols(int firstDateOffset, int lastDateOffset)
firstDateOffset
- fast access offset of first datelastDateOffset
- fast access offset of last date
public boolean containsQuote(Symbol symbol, int dateOffset)
symbol
- symboldateOffset
- fast access date offset
TRUE
if we have the quotepublic void load(EODQuote quote)
quote
- the quotepublic void load(Symbol symbol, TradingDate date, int day_volume, float day_low, float day_high, float day_open, float day_close)
symbol
- symbol of quotedate
- quote dateday_volume
- day volumeday_low
- day lowday_high
- day highday_open
- day openday_close
- day closepublic void free(Symbol symbol, int dateOffset)
symbol
- the symbol of the quote to removedateOffset
- the fast access date offset of the quote to removepublic int dateToOffset(TradingDate date) throws WeekendDateException
date
- the date
WeekendDateException
- if the date is on a weekend (there are no
fast access date offsets for weekend dates)public TradingDate offsetToDate(int dateOffset)
dateOffset
- fast access date offset
public int size()
public TradingDate getFirstDate()
null
if the cache is empty.public TradingDate getLastDate()
null
if the cache is empty.public int getFirstDateOffset()
|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |