|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mov.quote.QuoteFunctions
public class QuoteFunctions
This class contains functions that manipulate stock quotes. By placing them together in a single class, they can be used by both the Gondola language and charting functions.
QuoteFunctionSource
Field Summary | |
---|---|
static int |
DEFAULT_RSI_PERIOD
This is the default/recommended period for the RSI. |
Method Summary | |
---|---|
static double |
avg(double[] values,
int start,
int end)
|
static double |
avg(QuoteFunctionSource source,
int period)
Find the average of the given quotes. |
static double |
bestFit(QuoteFunctionSource source,
int period)
Calculate the line of best fit of the data given by source. |
static double[] |
bestFitFunction(QuoteFunctionSource source,
int start,
int period)
Return the equation of the line of best fit of the data given by source. |
static double |
bollingerLower(QuoteFunctionSource source,
int period)
Calculate the lower band of the bollinger graph. |
static double |
bollingerUpper(QuoteFunctionSource source,
int period)
Calculate the upper band of the bollinger graph. |
static double |
corr(QuoteFunctionSource x,
QuoteFunctionSource y,
int period)
Calculate the Pearson product-moment correlation between the two variables. |
static double |
ema(QuoteFunctionSource source,
int period,
double smoothingConstant)
Calculate the Exponential Moving Average (EMA) value. |
static double |
macd(QuoteFunctionSource sourceSlow,
QuoteFunctionSource sourceFast)
Calculate the Moving Average Convergence Divergence (MACD) value. |
static double |
momentum(QuoteFunctionSource source,
int period)
Calculate the Momentum value. |
static int |
obv(QuoteFunctionSource sourceOpen,
QuoteFunctionSource sourceClose,
QuoteFunctionSource sourceVolume,
int range,
int initialValue)
Calculate the On Balance Volume (OBV) value. |
static double |
roundDouble(double d,
int places)
|
static double |
rsi(QuoteFunctionSource source,
int period)
Calculate the Relative Strength Indicator (RSI) value. |
static double |
sd(double[] values,
int start,
int end)
|
static double |
sd(QuoteFunctionSource source,
int period)
Find the standard deviation of the given values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_RSI_PERIOD
Method Detail |
---|
public static double sd(QuoteFunctionSource source, int period) throws EvaluationException
source
- the source quottesperiod
- the number of days to average
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.StandardDeviationGraph
public static double sd(double[] values, int start, int end)
public static double avg(QuoteFunctionSource source, int period) throws EvaluationException
source
- source of quotes to averageperiod
- the number of days to average
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.MovingAverageGraph
,
AvgExpression
public static double avg(double[] values, int start, int end)
public static double corr(QuoteFunctionSource x, QuoteFunctionSource y, int period) throws EvaluationException
r = sum(Zx * Zy) ------------ N - 1 Where Zx = X - E(X) -------- SxWhere E(X) is the mean of X and Sx is the standard deviation of X. Simillarly for Zy.
x
- values to test againsty
- values to detect correlation against xperiod
- number of days to analyse
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.CorrExpression
public static double rsi(QuoteFunctionSource source, int period) throws EvaluationException
100 RSI = 100 - ------ 1 + RS average of x days' up closes RS = ------------------------------ average of x days' down closesTo calculate an X day RSI you need X + 1 quote values. So make the period argument one more day that the period of the RSI.
source
- source of quotes to averageperiod
- one plus the period of the RSI
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.RSIGraph
,
RSIExpression
public static double ema(QuoteFunctionSource source, int period, double smoothingConstant) throws EvaluationException
k
is a smoothing
constant.
source
- the source of quotes to averageperiod
- the number of days to analysesmoothingConstant
- a smoothing constant
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.ExpMovingAverageGraph
public static double macd(QuoteFunctionSource sourceSlow, QuoteFunctionSource sourceFast) throws EvaluationException
sourceSlow
- the source of quotes used by EMA to average (slow average)sourceFast
- the source of quotes used by EMA to average (fast average)
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.MACDGraph
public static double momentum(QuoteFunctionSource source, int period) throws EvaluationException
source
- the source of quotes
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.MomentumGraph
public static int obv(QuoteFunctionSource sourceOpen, QuoteFunctionSource sourceClose, QuoteFunctionSource sourceVolume, int range, int initialValue) throws EvaluationException
sourceOpen
- the source of open quotessourceClose
- the source of close quotessourceVolume
- the source of volumesrange
- the range which we calculate overinitialValue
- the starting value of OBV
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.OBVGraph
public static double bollingerUpper(QuoteFunctionSource source, int period) throws EvaluationException
source
- the source of quotesperiod
- the number of days to analyse
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.BollingerBandsGraph
public static double bollingerLower(QuoteFunctionSource source, int period) throws EvaluationException
source
- the source of quotesperiod
- the number of days to analyse
EvaluationException
- if QuoteBundleFunctionSource
is not
allowed access to a quote. See GPQuoteBundle
.BollingerBandsGraph
public static final double roundDouble(double d, int places)
public static double bestFit(QuoteFunctionSource source, int period) throws EvaluationException
source
- the source of quotesperiod
- the number of days to analyse
EvaluationException
public static double[] bestFitFunction(QuoteFunctionSource source, int start, int period) throws EvaluationException
source
- the source of quotesperiod
- the number of days to analyse
EvaluationException
|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |