use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class MedianPriceIndicatorTest method setUp.
@Before
public void setUp() {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(0, 0, 16, 8));
bars.add(new MockBar(0, 0, 12, 6));
bars.add(new MockBar(0, 0, 18, 14));
bars.add(new MockBar(0, 0, 10, 6));
bars.add(new MockBar(0, 0, 32, 6));
bars.add(new MockBar(0, 0, 2, 2));
bars.add(new MockBar(0, 0, 0, 0));
bars.add(new MockBar(0, 0, 8, 1));
bars.add(new MockBar(0, 0, 83, 32));
bars.add(new MockBar(0, 0, 9, 3));
this.timeSeries = new MockTimeSeries(bars);
average = new MedianPriceIndicator(timeSeries);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class ATRIndicatorTest method testDummy.
@Test
public void testDummy() throws Exception {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(0, 12, 15, 8));
bars.add(new MockBar(0, 8, 11, 6));
bars.add(new MockBar(0, 15, 17, 14));
bars.add(new MockBar(0, 15, 17, 14));
bars.add(new MockBar(0, 0, 0, 2));
Indicator<Decimal> indicator = getIndicator(new MockTimeSeries(bars), 3);
assertEquals(7d, indicator.getValue(0).doubleValue(), TATestsUtils.TA_OFFSET);
assertEquals(6d / 3 + (1 - 1d / 3) * indicator.getValue(0).doubleValue(), indicator.getValue(1).doubleValue(), TATestsUtils.TA_OFFSET);
assertEquals(9d / 3 + (1 - 1d / 3) * indicator.getValue(1).doubleValue(), indicator.getValue(2).doubleValue(), TATestsUtils.TA_OFFSET);
assertEquals(3d / 3 + (1 - 1d / 3) * indicator.getValue(2).doubleValue(), indicator.getValue(3).doubleValue(), TATestsUtils.TA_OFFSET);
assertEquals(15d / 3 + (1 - 1d / 3) * indicator.getValue(3).doubleValue(), indicator.getValue(4).doubleValue(), TATestsUtils.TA_OFFSET);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class AccelerationDecelerationIndicatorTest method setUp.
@Before
public void setUp() {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(0, 0, 16, 8));
bars.add(new MockBar(0, 0, 12, 6));
bars.add(new MockBar(0, 0, 18, 14));
bars.add(new MockBar(0, 0, 10, 6));
bars.add(new MockBar(0, 0, 8, 4));
series = new MockTimeSeries(bars);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class CCIIndicatorTest method setUp.
@Before
public void setUp() {
ArrayList<Bar> bars = new ArrayList<Bar>();
for (Double price : typicalPrices) {
bars.add(new MockBar(price, price, price, price));
}
series = new MockTimeSeries(bars);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class EMAIndicatorTest method stackOverflowError.
@Test
public void stackOverflowError() throws Exception {
List<Bar> bigListOfBars = new ArrayList<Bar>();
for (int i = 0; i < 10000; i++) {
bigListOfBars.add(new MockBar(i));
}
MockTimeSeries bigSeries = new MockTimeSeries(bigListOfBars);
Indicator<Decimal> indicator = getIndicator(new ClosePriceIndicator(bigSeries), 10);
// if a StackOverflowError is thrown here, then the RecursiveCachedIndicator does not work as intended.
assertDecimalEquals(indicator.getValue(9999), 9994.5);
}
Aggregations