Search in sources :

Example 1 with MockBar

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

the class CorrelationCoefficientIndicatorTest method setUp.

@Before
public void setUp() {
    List<Bar> bars = new ArrayList<Bar>();
    // close, volume
    bars.add(new MockBar(6, 100));
    bars.add(new MockBar(7, 105));
    bars.add(new MockBar(9, 130));
    bars.add(new MockBar(12, 160));
    bars.add(new MockBar(11, 150));
    bars.add(new MockBar(10, 130));
    bars.add(new MockBar(11, 95));
    bars.add(new MockBar(13, 120));
    bars.add(new MockBar(15, 180));
    bars.add(new MockBar(12, 160));
    bars.add(new MockBar(8, 150));
    bars.add(new MockBar(4, 200));
    bars.add(new MockBar(3, 150));
    bars.add(new MockBar(4, 85));
    bars.add(new MockBar(3, 70));
    bars.add(new MockBar(5, 90));
    bars.add(new MockBar(8, 100));
    bars.add(new MockBar(9, 95));
    bars.add(new MockBar(11, 110));
    bars.add(new MockBar(10, 95));
    TimeSeries data = new BaseTimeSeries(bars);
    close = new ClosePriceIndicator(data);
    volume = new VolumeIndicator(data, 2);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) VolumeIndicator(org.ta4j.core.indicators.helpers.VolumeIndicator) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Before(org.junit.Before)

Example 2 with MockBar

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

the class CovarianceIndicatorTest method setUp.

@Before
public void setUp() {
    List<Bar> bars = new ArrayList<Bar>();
    // close, volume
    bars.add(new MockBar(6, 100));
    bars.add(new MockBar(7, 105));
    bars.add(new MockBar(9, 130));
    bars.add(new MockBar(12, 160));
    bars.add(new MockBar(11, 150));
    bars.add(new MockBar(10, 130));
    bars.add(new MockBar(11, 95));
    bars.add(new MockBar(13, 120));
    bars.add(new MockBar(15, 180));
    bars.add(new MockBar(12, 160));
    bars.add(new MockBar(8, 150));
    bars.add(new MockBar(4, 200));
    bars.add(new MockBar(3, 150));
    bars.add(new MockBar(4, 85));
    bars.add(new MockBar(3, 70));
    bars.add(new MockBar(5, 90));
    bars.add(new MockBar(8, 100));
    bars.add(new MockBar(9, 95));
    bars.add(new MockBar(11, 110));
    bars.add(new MockBar(10, 95));
    TimeSeries data = new BaseTimeSeries(bars);
    close = new ClosePriceIndicator(data);
    volume = new VolumeIndicator(data, 2);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) VolumeIndicator(org.ta4j.core.indicators.helpers.VolumeIndicator) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Before(org.junit.Before)

Example 3 with MockBar

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

the class PearsonCorrelationIndicatorTest method setUp.

@Before
public void setUp() {
    List<Bar> bars = new ArrayList<Bar>();
    // close, volume
    bars.add(new MockBar(6, 100));
    bars.add(new MockBar(7, 105));
    bars.add(new MockBar(9, 130));
    bars.add(new MockBar(12, 160));
    bars.add(new MockBar(11, 150));
    bars.add(new MockBar(10, 130));
    bars.add(new MockBar(11, 95));
    bars.add(new MockBar(13, 120));
    bars.add(new MockBar(15, 180));
    bars.add(new MockBar(12, 160));
    bars.add(new MockBar(8, 150));
    bars.add(new MockBar(4, 200));
    bars.add(new MockBar(3, 150));
    bars.add(new MockBar(4, 85));
    bars.add(new MockBar(3, 70));
    bars.add(new MockBar(5, 90));
    bars.add(new MockBar(8, 100));
    bars.add(new MockBar(9, 95));
    bars.add(new MockBar(11, 110));
    bars.add(new MockBar(10, 95));
    TimeSeries data = new BaseTimeSeries(bars);
    close = new ClosePriceIndicator(data);
    volume = new VolumeIndicator(data, 2);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) VolumeIndicator(org.ta4j.core.indicators.helpers.VolumeIndicator) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Before(org.junit.Before)

Example 4 with MockBar

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

the class PlusDMIndicatorTest method zeroDirectionalMovement3.

@Test
public void zeroDirectionalMovement3() {
    MockBar yesterdayBar = new MockBar(0, 0, 6, 20);
    MockBar todayBar = new MockBar(0, 0, 12, 4);
    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 5 with MockBar

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

the class PlusDMIndicatorTest method positiveDirectionalMovement.

@Test
public void positiveDirectionalMovement() {
    MockBar yesterdayBar = new MockBar(0, 0, 6, 6);
    MockBar todayBar = new MockBar(0, 0, 12, 4);
    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), 6);
}
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)

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