Search in sources :

Example 41 with MockBar

use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.

the class ROCVIndicatorTest method setUp.

@Before
public void setUp() {
    List<Bar> bars = new ArrayList<Bar>();
    bars.add(new MockBar(1355.69, 1000));
    bars.add(new MockBar(1325.51, 3000));
    bars.add(new MockBar(1335.02, 3500));
    bars.add(new MockBar(1313.72, 2200));
    bars.add(new MockBar(1319.99, 2300));
    bars.add(new MockBar(1331.85, 200));
    bars.add(new MockBar(1329.04, 2700));
    bars.add(new MockBar(1362.16, 5000));
    bars.add(new MockBar(1365.51, 1000));
    bars.add(new MockBar(1374.02, 2500));
    series = new MockTimeSeries(bars);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) Bar(org.ta4j.core.Bar) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Before(org.junit.Before)

Example 42 with MockBar

use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.

the class PlusDMIndicatorTest method zeroDirectionalMovement.

@Test
public void zeroDirectionalMovement() {
    MockBar yesterdayBar = new MockBar(0, 0, 10, 2);
    MockBar todayBar = new MockBar(0, 0, 6, 6);
    List<Bar> bars = new ArrayList<Bar>();
    bars.add(yesterdayBar);
    bars.add(todayBar);
    MockTimeSeries series = new MockTimeSeries(bars);
    PlusDMIndicator dup = new PlusDMIndicator(series);
    assertDecimalEquals(dup.getValue(1), 0);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) Bar(org.ta4j.core.Bar) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Example 43 with MockBar

use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.

the class TRIndicatorTest method getValue.

@Test
public void getValue() {
    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));
    TRIndicator tr = new TRIndicator(new MockTimeSeries(bars));
    assertDecimalEquals(tr.getValue(0), 7);
    assertDecimalEquals(tr.getValue(1), 6);
    assertDecimalEquals(tr.getValue(2), 9);
    assertDecimalEquals(tr.getValue(3), 3);
    assertDecimalEquals(tr.getValue(4), 15);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) Bar(org.ta4j.core.Bar) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Example 44 with MockBar

use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.

the class VolumeIndicatorTest method sumOfVolume.

@Test
public void sumOfVolume() {
    List<Bar> bars = new ArrayList<Bar>();
    bars.add(new MockBar(0, 10));
    bars.add(new MockBar(0, 11));
    bars.add(new MockBar(0, 12));
    bars.add(new MockBar(0, 13));
    bars.add(new MockBar(0, 150));
    bars.add(new MockBar(0, 155));
    bars.add(new MockBar(0, 160));
    VolumeIndicator volumeIndicator = new VolumeIndicator(new MockTimeSeries(bars), 3);
    assertDecimalEquals(volumeIndicator.getValue(0), 10);
    assertDecimalEquals(volumeIndicator.getValue(1), 21);
    assertDecimalEquals(volumeIndicator.getValue(2), 33);
    assertDecimalEquals(volumeIndicator.getValue(3), 36);
    assertDecimalEquals(volumeIndicator.getValue(4), 175);
    assertDecimalEquals(volumeIndicator.getValue(5), 318);
    assertDecimalEquals(volumeIndicator.getValue(6), 465);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) Bar(org.ta4j.core.Bar) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Example 45 with MockBar

use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.

the class IchimokuIndicatorTest 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);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) Bar(org.ta4j.core.Bar) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Before(org.junit.Before)

Aggregations

MockBar (org.ta4j.core.mocks.MockBar)57 ArrayList (java.util.ArrayList)54 Bar (org.ta4j.core.Bar)48 MockTimeSeries (org.ta4j.core.mocks.MockTimeSeries)46 Before (org.junit.Before)35 Test (org.junit.Test)22 BaseTimeSeries (org.ta4j.core.BaseTimeSeries)6 TimeSeries (org.ta4j.core.TimeSeries)5 ClosePriceIndicator (org.ta4j.core.indicators.helpers.ClosePriceIndicator)5 ZonedDateTime (java.time.ZonedDateTime)3 VolumeIndicator (org.ta4j.core.indicators.helpers.VolumeIndicator)3 BaseTradingRecord (org.ta4j.core.BaseTradingRecord)1 TradingRecord (org.ta4j.core.TradingRecord)1 FixedRule (org.ta4j.core.trading.rules.FixedRule)1