use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class TimeSeriesTest method addBar.
@Test
public void addBar() {
defaultSeries = new BaseTimeSeries();
Bar firstBar = new MockBar(ZonedDateTime.of(2014, 6, 13, 0, 0, 0, 0, ZoneId.systemDefault()), 1d);
Bar secondBar = new MockBar(ZonedDateTime.of(2014, 6, 14, 0, 0, 0, 0, ZoneId.systemDefault()), 2d);
assertEquals(0, defaultSeries.getBarCount());
assertEquals(-1, defaultSeries.getBeginIndex());
assertEquals(-1, defaultSeries.getEndIndex());
defaultSeries.addBar(firstBar);
assertEquals(1, defaultSeries.getBarCount());
assertEquals(0, defaultSeries.getBeginIndex());
assertEquals(0, defaultSeries.getEndIndex());
defaultSeries.addBar(secondBar);
assertEquals(2, defaultSeries.getBarCount());
assertEquals(0, defaultSeries.getBeginIndex());
assertEquals(1, defaultSeries.getEndIndex());
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class CloseLocationValueIndicatorTest method setUp.
@Before
public void setUp() {
List<Bar> bars = new ArrayList<Bar>();
// open, close, high, low
bars.add(new MockBar(10, 18, 20, 10));
bars.add(new MockBar(17, 20, 21, 17));
bars.add(new MockBar(15, 15, 16, 14));
bars.add(new MockBar(15, 11, 15, 8));
bars.add(new MockBar(11, 12, 12, 10));
series = new MockTimeSeries(bars);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class CashFlowTest method reallyLongCashFlow.
@Test
public void reallyLongCashFlow() {
int size = 1000000;
TimeSeries sampleTimeSeries = new MockTimeSeries(Collections.nCopies(size, new MockBar(10)));
TradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, sampleTimeSeries), Order.sellAt(size - 1, sampleTimeSeries));
CashFlow cashFlow = new CashFlow(sampleTimeSeries, tradingRecord);
assertDecimalEquals(cashFlow.getValue(size - 1), 1);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class RandomWalkIndexHighIndicatorTest method setUp.
@Before
public void setUp() {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(44.98, 45.05, 45.17, 44.96));
bars.add(new MockBar(45.05, 45.10, 45.15, 44.99));
bars.add(new MockBar(45.11, 45.19, 45.32, 45.11));
bars.add(new MockBar(45.19, 45.14, 45.25, 45.04));
bars.add(new MockBar(45.12, 45.15, 45.20, 45.10));
bars.add(new MockBar(45.15, 45.14, 45.20, 45.10));
bars.add(new MockBar(45.13, 45.10, 45.16, 45.07));
bars.add(new MockBar(45.12, 45.15, 45.22, 45.10));
bars.add(new MockBar(45.15, 45.22, 45.27, 45.14));
bars.add(new MockBar(45.24, 45.43, 45.45, 45.20));
bars.add(new MockBar(45.43, 45.44, 45.50, 45.39));
bars.add(new MockBar(45.43, 45.55, 45.60, 45.35));
bars.add(new MockBar(45.58, 45.55, 45.61, 45.39));
bars.add(new MockBar(45.45, 45.01, 45.55, 44.80));
bars.add(new MockBar(45.03, 44.23, 45.04, 44.17));
bars.add(new MockBar(44.23, 43.95, 44.29, 43.81));
bars.add(new MockBar(43.91, 43.08, 43.99, 43.08));
bars.add(new MockBar(43.07, 43.55, 43.65, 43.06));
bars.add(new MockBar(43.56, 43.95, 43.99, 43.53));
bars.add(new MockBar(43.93, 44.47, 44.58, 43.93));
data = new MockTimeSeries(bars);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class StochasticOscillatorKIndicatorTest method setUp.
@Before
public void setUp() {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(44.98, 119.13, 119.50, 116.00));
bars.add(new MockBar(45.05, 116.75, 119.94, 116.00));
bars.add(new MockBar(45.11, 113.50, 118.44, 111.63));
bars.add(new MockBar(45.19, 111.56, 114.19, 110.06));
bars.add(new MockBar(45.12, 112.25, 112.81, 109.63));
bars.add(new MockBar(45.15, 110.00, 113.44, 109.13));
bars.add(new MockBar(45.13, 113.50, 115.81, 110.38));
bars.add(new MockBar(45.12, 117.13, 117.50, 114.06));
bars.add(new MockBar(45.15, 115.63, 118.44, 114.81));
bars.add(new MockBar(45.24, 114.13, 116.88, 113.13));
bars.add(new MockBar(45.43, 118.81, 119.00, 116.19));
bars.add(new MockBar(45.43, 117.38, 119.75, 117.00));
bars.add(new MockBar(45.58, 119.13, 119.13, 116.88));
bars.add(new MockBar(45.58, 115.38, 119.44, 114.56));
data = new BaseTimeSeries(bars);
}
Aggregations