@Test public void testGetTotalReturn() { PeriodicalGrowthRateIndicator gri = new PeriodicalGrowthRateIndicator(this.closePrice, 5); double expResult = 0.9564; double result = gri.getTotalReturn(); assertEquals(expResult, result, 0.01); }
public double getTotalReturn() { Decimal totalProduct = Decimal.ONE; int completeTimeframes = (getTimeSeries().getTickCount() / timeFrame); for (int i = 1; i <= completeTimeframes; i++) { int index = i * timeFrame; Decimal currentReturn = getValue(index); if (currentReturn != Decimal.NaN) { currentReturn = currentReturn.plus(Decimal.ONE); totalProduct = totalProduct.multipliedBy(currentReturn); } } return (Math.pow(totalProduct.toDouble(), (1.0 / completeTimeframes))); }
PeriodicalGrowthRateIndicator extends CachedIndicator<Decimal> { public double getTotalReturn() { Decimal totalProduct = Decimal.ONE; int completeTimeframes = (getTimeSeries().getTickCount() / timeFrame); for (int i = 1; i <= completeTimeframes; i++) { int index = i * timeFrame; Decimal currentReturn = getValue(index); if (currentReturn != Decimal.NaN) { currentReturn = currentReturn.plus(Decimal.ONE); totalProduct = totalProduct.multipliedBy(currentReturn); } } return (Math.pow(totalProduct.toDouble(), (1.0 / completeTimeframes))); } }
PeriodicalGrowthRateIndicator extends CachedIndicator<Decimal> { public double getTotalReturn() { Decimal totalProduct = Decimal.ONE; int completeTimeframes = (getTimeSeries().getTickCount() / timeFrame); for (int i = 1; i <= completeTimeframes; i++) { int index = i * timeFrame; Decimal currentReturn = getValue(index); if (currentReturn != Decimal.NaN) { currentReturn = currentReturn.plus(Decimal.ONE); totalProduct = totalProduct.multipliedBy(currentReturn); } } return (Math.pow(totalProduct.toDouble(), (1.0 / completeTimeframes))); } PeriodicalGrowthRateIndicator(Indicator<Decimal> indicator, int timeFrame); }
PeriodicalGrowthRateIndicator extends CachedIndicator<Decimal> { public double getTotalReturn() { Decimal totalProduct = Decimal.ONE; int completeTimeframes = (getTimeSeries().getTickCount() / timeFrame); for (int i = 1; i <= completeTimeframes; i++) { int index = i * timeFrame; Decimal currentReturn = getValue(index); if (currentReturn != Decimal.NaN) { currentReturn = currentReturn.plus(Decimal.ONE); totalProduct = totalProduct.multipliedBy(currentReturn); } } return (Math.pow(totalProduct.toDouble(), (1.0 / completeTimeframes))); } PeriodicalGrowthRateIndicator(Indicator<Decimal> indicator, int timeFrame); double getTotalReturn(); }
PeriodicalGrowthRateIndicator extends CachedIndicator<Decimal> { public double getTotalReturn() { Decimal totalProduct = Decimal.ONE; int completeTimeframes = (getTimeSeries().getTickCount() / timeFrame); for (int i = 1; i <= completeTimeframes; i++) { int index = i * timeFrame; Decimal currentReturn = getValue(index); if (currentReturn != Decimal.NaN) { currentReturn = currentReturn.plus(Decimal.ONE); totalProduct = totalProduct.multipliedBy(currentReturn); } } return (Math.pow(totalProduct.toDouble(), (1.0 / completeTimeframes))); } PeriodicalGrowthRateIndicator(Indicator<Decimal> indicator, int timeFrame); double getTotalReturn();  }