@Test public void testGetTotalReturn() { PeriodicalGrowthRateIndicator gri = new PeriodicalGrowthRateIndicator(this.closePrice, 5); Num result = gri.getTotalReturn(); assertNumEquals(0.9564, result); }
public Num getTotalReturn() { Num totalProduct = one; int completeTimeFrames = (getBarSeries().getBarCount() / barCount); for (int i = 1; i <= completeTimeFrames; i++) { int index = i * barCount; Num currentReturn = getValue(index); if (currentReturn != NaN) { currentReturn = currentReturn.plus(one); totalProduct = totalProduct.multipliedBy(currentReturn); } } return totalProduct.pow(one.dividedBy(numOf(completeTimeFrames))); }
PeriodicalGrowthRateIndicator extends CachedIndicator<Num> { public Num getTotalReturn() { Num totalProduct = one; int completeTimeFrames = (getBarSeries().getBarCount() / barCount); for (int i = 1; i <= completeTimeFrames; i++) { int index = i * barCount; Num currentReturn = getValue(index); if (currentReturn != NaN) { currentReturn = currentReturn.plus(one); totalProduct = totalProduct.multipliedBy(currentReturn); } } return totalProduct.pow(one.dividedBy(numOf(completeTimeFrames))); } }
PeriodicalGrowthRateIndicator extends CachedIndicator<Num> { public Num getTotalReturn() { Num totalProduct = one; int completeTimeFrames = (getBarSeries().getBarCount() / barCount); for (int i = 1; i <= completeTimeFrames; i++) { int index = i * barCount; Num currentReturn = getValue(index); if (currentReturn != NaN) { currentReturn = currentReturn.plus(one); totalProduct = totalProduct.multipliedBy(currentReturn); } } return totalProduct.pow(one.dividedBy(numOf(completeTimeFrames))); } PeriodicalGrowthRateIndicator(Indicator<Num> indicator, int barCount); }
PeriodicalGrowthRateIndicator extends CachedIndicator<Num> { public Num getTotalReturn() { Num totalProduct = one; int completeTimeFrames = (getBarSeries().getBarCount() / barCount); for (int i = 1; i <= completeTimeFrames; i++) { int index = i * barCount; Num currentReturn = getValue(index); if (currentReturn != NaN) { currentReturn = currentReturn.plus(one); totalProduct = totalProduct.multipliedBy(currentReturn); } } return totalProduct.pow(one.dividedBy(numOf(completeTimeFrames))); } PeriodicalGrowthRateIndicator(Indicator<Num> indicator, int barCount); Num getTotalReturn(); }
PeriodicalGrowthRateIndicator extends CachedIndicator<Num> { public Num getTotalReturn() { Num totalProduct = one; int completeTimeFrames = (getBarSeries().getBarCount() / barCount); for (int i = 1; i <= completeTimeFrames; i++) { int index = i * barCount; Num currentReturn = getValue(index); if (currentReturn != NaN) { currentReturn = currentReturn.plus(one); totalProduct = totalProduct.multipliedBy(currentReturn); } } return totalProduct.pow(one.dividedBy(numOf(completeTimeFrames))); } PeriodicalGrowthRateIndicator(Indicator<Num> indicator, int barCount); Num getTotalReturn();  }