|
WebCab Technical Analysis v1.1 (J2SE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--webcab.lib.finance.trading.indicators.Volatility
Allows the Volatility (Historical Estimate with(out) dividends, Standard Error) and the effect of Volatility (Chaikin's Volatility indicator) to be measured.
For many of the indicators we provide essentially two versions of the same method. The first version evaluates the indicator over the entire period given and the second version evaluates the indicator over all the sub-periods of a given length. Moreover, the version which evaluates over all sub-periods of a given length will return the results as an array where the 1st term of the array will be the value associated with the most recent sub-period, and the previous element corresponding to the previous sub-period and so on.
The naming of these two versions will follow the convention that if the indicator which
evaluates over the entire period and returns a single element is named ABCIndicator,
then the corresponding indicator over all sub-periods (of a given length) which returns
an array will be denoted by ABCIndicatorOverPeriod.
For example, if our source data has N elements then the two versions
of a given indicator, where the number of periods used within the sub-periods is
n would correspond to:
ABCIndicator - Evaluation the indicator over the whole period of length N.ABCIndicatorOverPeriod - Will return an array where the
first term is the value of the indicator ABCIndicator on the most recent n
periods, and the next term is the value of the indicator ABCIndicator on the
previous n+1 periods minus the most recent period and so on. That is,
for each iterative evaluation 'the window of evaluation' is shifted one place back.
| Constructor Summary | |
Volatility()
Creates a new instance. |
|
| Method Summary | |
double[] |
chaikinVolatility(double[] highs,
double[] lows,
int lengthOfMA,
int noOfPeriods)
Evaluates Chaikin's Volatility indicator over a period which compares the spread between a security's high and low prices. |
double |
historicalEstimate(double[] assetPrices)
Evaluates the historical estimate of the present volatility. |
double |
historicalEstimateStandardError(double numberOfPeriods,
double volatilityEstimate)
Returns the estimate of the standard error of the standard historical estimation given by the functions historicalEstimate(double[]) and
historicalEstimateWithDividends(double[], double[]).
|
double |
historicalEstimateWithDividends(double[] assetPrices,
double[] dividendsPaid)
Calculates the historical estimate of the present volatility taking into account the dividends or interest payments of the underlying asset. |
double |
returnDuringithPeriod(double ithPeriodAssetPrice,
double i_1thPeriodAssetPrice)
Evaluates the continuously compounded return of an asset over one period (for example a period). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Volatility()
| Method Detail |
public double[] chaikinVolatility(double[] highs,
double[] lows,
int lengthOfMA,
int noOfPeriods)
The formula for this indicator is:
chaikinVolatility = 100.( (HLAverage - HLAverage_n_periods_ago) / HLAverage_n_periods_ago ),
where HLAverage is the Exponential Moving Average of the difference between high
and low of the current trading period, and HLAverage_n_periods_ago is the
Exponential Moving Average of the difference between high and low of the trading period
from n periods ago.
highs - an array of the trading highs over the last n-periods where the k-th terms of the array if the high on the k-th previous period.lows - an array of the trading lows over the last n-periods where the k-th terms of the array if the trading lows on the k-th previous period.lengthOfMA - the number of periods considered within the evaluation of the moving average for each of the periods on which it can be evaluated.noOfPeriods - an integer which represents the number of previous time periods used over which the moving averages are compared.
highs array minus the
length of the moving average (lengthOfMA) where the 1st term of this array
is the value of the indicator of the most resent period and the 2nd term of this array
is the value of the indicator on the previous period and so on.
IllegalArgumentException - thrown if either parameter is strictly negative or arrays closes or
volumes are empty.
IllegalArgumentException - if the length of the highs and lows
parameters provided are not equal.public double historicalEstimate(double[] assetPrices)
The historical estimate is evaluated using a given number of historical values of the assets market price. Care should be taken when deciding on the number of historical values to use within the historical estimate of the present volatility. A balance needs to be made between using a large sample (resulting in the small standard error) and a smaller sample which does not take too distant historical values which may not fully reflect the present market dynamics. As a rule of thumb the number of periods used in order to historical estimate the present daily volatility should (in generally) be between 90 and 180 periods.
assetPrices - an array of the assets price at the end of each interval where the 1st term is the most recent asset price and the 2nd term is the previous periods asset price and so on. Note that if we use daily values of the asset price then this methods will return an estimate of the daily volatility.
historicalEstimateWithDividends
public double historicalEstimateStandardError(double numberOfPeriods,
double volatilityEstimate)
historicalEstimate(double[]) and
historicalEstimateWithDividends(double[], double[]).
Recall that the standard error is the standard deviation of the sampling distribution of that statistic. Standard errors are important because they reflect how much sampling fluctuations effect the reliability of the statistic, in this case the estimate of the volatility. The standard error of a statistic will depend on the sample size where generally the larger the sample size the smaller the standard error will be.
numberOfPeriods - the number of periods over which the historical data is used within the estimate of the volatility.volatilityEstimate - estimate of the volatility per annum
historicalEstimate and historicalEstimateWithDividends.
public double historicalEstimateWithDividends(double[] assetPrices,
double[] dividendsPaid)
throws IndicatorsException
The historical estimate is evaluated using a given number of historical values of the assets market price. Care should be taken when deciding on the number of historical values to use within the historical estimate of the present volatility. A balance needs to be made between using a large sample (resulting in the small standard error) and a smaller sample which does not take too distant historical values which may not fully reflect the present market dynamics. As a rule of thumb the number of days used in order to historical estimate the present daily volatility should (in generally) be between 90 and 180 days.
assetPrices - an array where the k-th term is the assets market value at the end of the k-th interval. Note that if we use daily values of the asset price then this method will return an estimate of the daily volatility.dividendsPaid - an array where the k-th term corresponds to the dividends (or interest payments) from the asset within the k-th period. If we are estimating the daily volatility then the periods considered will correspond to days. The length of the array corresponding to the dividends (or interest payments) must have the same length as the array of asset prices used. If no payment is made within the i-th interval then the i-th element of the array in zero.
OptionException - thrown when the number of asset prices is not equal to
the number of dividends
IndicatorsExceptionhistoricalEstimate(double[])
public double returnDuringithPeriod(double ithPeriodAssetPrice,
double i_1thPeriodAssetPrice)
ithPeriodAssetPrice - this in the asset price at the close of business on the ith period (this period could be a period or a month etc).i_1thPeriodAssetPrice - this is the asset price at the close of business on the i-1th period (this period could be a period or a month etc).
|
WebCab Technical Analysis v1.1 (J2SE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||