use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class AbstractIndicatorTest method getTimeSeries.
@Test
public void getTimeSeries() {
ClosePriceIndicator cp = new ClosePriceIndicator(series);
assertEquals(series, cp.getTimeSeries());
SMAIndicator sma = new SMAIndicator(cp, 3);
assertEquals(series, sma.getTimeSeries());
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class CachedIndicatorTest method recursiveCachedIndicatorOnMovingTimeSeriesShouldNotCauseStackOverflow.
@Test
public void recursiveCachedIndicatorOnMovingTimeSeriesShouldNotCauseStackOverflow() {
// Added to check issue #120: https://github.com/mdeverdelhan/ta4j/issues/120
// See also: CachedIndicator#getValue(int index)
series = new MockTimeSeries();
series.setMaximumBarCount(5);
assertEquals(5, series.getBarCount());
ZLEMAIndicator zlema = new ZLEMAIndicator(new ClosePriceIndicator(series), 1);
try {
assertDecimalEquals(zlema.getValue(8), "4996");
} catch (Throwable t) {
fail(t.getMessage());
}
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class CachedIndicatorTest method getValueOnResultsCalculatedFromRemovedBarsShouldReturnFirstRemainingResult.
@Test
public void getValueOnResultsCalculatedFromRemovedBarsShouldReturnFirstRemainingResult() {
TimeSeries timeSeries = new MockTimeSeries(1, 1, 1, 1, 1);
timeSeries.setMaximumBarCount(3);
assertEquals(2, timeSeries.getRemovedBarsCount());
SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(timeSeries), 2);
for (int i = 0; i < 5; i++) {
assertDecimalEquals(sma.getValue(i), 1);
}
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class CachedIndicatorTest method ifCacheWorks.
@Test
public void ifCacheWorks() {
SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(series), 3);
Decimal firstTime = sma.getValue(4);
Decimal secondTime = sma.getValue(4);
assertEquals(firstTime, secondTime);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class CachedIndicatorTest method getValueWithOldResultsRemoval.
@Test
public void getValueWithOldResultsRemoval() {
double[] data = new double[20];
Arrays.fill(data, 1);
TimeSeries timeSeries = new MockTimeSeries(data);
SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(timeSeries), 10);
assertDecimalEquals(sma.getValue(5), 1);
assertDecimalEquals(sma.getValue(10), 1);
timeSeries.setMaximumBarCount(12);
assertDecimalEquals(sma.getValue(19), 1);
}
Aggregations