Search in sources :

Example 1 with MockTimeSeries

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

the class SimpleLinearRegressionIndicatorTest method setUp.

@Before
public void setUp() {
    double[] data = new double[] { 10, 20, 30, 40, 30, 40, 30, 20, 30, 50, 60, 70, 80 };
    closePrice = new ClosePriceIndicator(new MockTimeSeries(data));
}
Also used : MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Before(org.junit.Before)

Example 2 with MockTimeSeries

use of org.ta4j.core.mocks.MockTimeSeries 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 3 with MockTimeSeries

use of org.ta4j.core.mocks.MockTimeSeries 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)

Example 4 with MockTimeSeries

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

the class PlusDMIndicatorTest method zeroDirectionalMovement2.

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

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

the class PriceVariationIndicatorTest method setUp.

@Before
public void setUp() {
    timeSeries = new MockTimeSeries();
    variationIndicator = new PriceVariationIndicator(timeSeries);
}
Also used : MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Before(org.junit.Before)

Aggregations

MockTimeSeries (org.ta4j.core.mocks.MockTimeSeries)135 Test (org.junit.Test)90 MockBar (org.ta4j.core.mocks.MockBar)46 ArrayList (java.util.ArrayList)45 Before (org.junit.Before)45 Bar (org.ta4j.core.Bar)42 TimeSeries (org.ta4j.core.TimeSeries)29 ClosePriceIndicator (org.ta4j.core.indicators.helpers.ClosePriceIndicator)25 BaseTradingRecord (org.ta4j.core.BaseTradingRecord)17 TradingRecord (org.ta4j.core.TradingRecord)12 ZonedDateTime (java.time.ZonedDateTime)5 AnalysisCriterion (org.ta4j.core.AnalysisCriterion)3 BaseStrategy (org.ta4j.core.BaseStrategy)3 ExternalCriterionTest (org.ta4j.core.ExternalCriterionTest)3 Strategy (org.ta4j.core.Strategy)3 Decimal (org.ta4j.core.Decimal)2 TimeSeriesManager (org.ta4j.core.TimeSeriesManager)2 Trade (org.ta4j.core.Trade)2 SMAIndicator (org.ta4j.core.indicators.SMAIndicator)2 FixedRule (org.ta4j.core.trading.rules.FixedRule)2