Search in sources :

Example 56 with MockTimeSeries

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

the class BearishHaramiIndicatorTest 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(15, 18, 19, 14));
    bars.add(new MockBar(17, 16, 19, 15));
    bars.add(new MockBar(15, 11, 15, 8));
    bars.add(new MockBar(11, 12, 12, 10));
    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 57 with MockTimeSeries

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

the class BullishEngulfingIndicatorTest 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, 16, 19, 15));
    bars.add(new MockBar(15, 18, 19, 14));
    bars.add(new MockBar(15, 11, 15, 8));
    bars.add(new MockBar(11, 12, 12, 10));
    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 58 with MockTimeSeries

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

the class DojiIndicatorTest method getValueAtIndex0.

@Test
public void getValueAtIndex0() {
    DojiIndicator doji = new DojiIndicator(new MockTimeSeries(0d), 10, Decimal.valueOf("0.03"));
    assertTrue(doji.getValue(0));
    doji = new DojiIndicator(new MockTimeSeries(1d), 10, Decimal.valueOf("0.03"));
    assertFalse(doji.getValue(0));
}
Also used : MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Example 59 with MockTimeSeries

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

the class TimeSeriesManagerTest method runOnWholeSeriesWithAmount.

@Test
public void runOnWholeSeriesWithAmount() {
    TimeSeries series = new MockTimeSeries(20d, 40d, 60d, 10d, 30d, 50d, 0d, 20d, 40d);
    manager.setTimeSeries(series);
    List<Trade> allTrades = manager.run(strategy, OrderType.BUY, Decimal.HUNDRED).getTrades();
    assertEquals(2, allTrades.size());
    assertEquals(Decimal.HUNDRED, allTrades.get(0).getEntry().getAmount());
    assertEquals(Decimal.HUNDRED, allTrades.get(1).getEntry().getAmount());
}
Also used : MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Example 60 with MockTimeSeries

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

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