Search in sources :

Example 11 with MockTimeSeries

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

the class MaxPriceIndicatorTest method setUp.

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

Example 12 with MockTimeSeries

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

the class MedianPriceIndicatorTest method setUp.

@Before
public void setUp() {
    List<Bar> bars = new ArrayList<Bar>();
    bars.add(new MockBar(0, 0, 16, 8));
    bars.add(new MockBar(0, 0, 12, 6));
    bars.add(new MockBar(0, 0, 18, 14));
    bars.add(new MockBar(0, 0, 10, 6));
    bars.add(new MockBar(0, 0, 32, 6));
    bars.add(new MockBar(0, 0, 2, 2));
    bars.add(new MockBar(0, 0, 0, 0));
    bars.add(new MockBar(0, 0, 8, 1));
    bars.add(new MockBar(0, 0, 83, 32));
    bars.add(new MockBar(0, 0, 9, 3));
    this.timeSeries = new MockTimeSeries(bars);
    average = new MedianPriceIndicator(timeSeries);
}
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 13 with MockTimeSeries

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

the class OpenPriceIndicatorTest method setUp.

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

Example 14 with MockTimeSeries

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

the class RewardRiskRatioCriterionTest method rewardRiskRatioCriterionOnlyWithGain.

@Test
public void rewardRiskRatioCriterionOnlyWithGain() {
    MockTimeSeries series = new MockTimeSeries(1, 2, 3, 6, 8, 20, 3);
    TradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, series), Order.sellAt(1, series), Order.buyAt(2, series), Order.sellAt(5, series));
    assertTrue(Double.isInfinite(rrc.calculate(series, tradingRecord)));
}
Also used : MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Example 15 with MockTimeSeries

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

the class TotalProfitCriterionTest method calculateOnlyWithLossTrades.

@Test
public void calculateOnlyWithLossTrades() {
    MockTimeSeries series = new MockTimeSeries(100, 95, 100, 80, 85, 70);
    TradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, series), Order.sellAt(1, series), Order.buyAt(2, series), Order.sellAt(5, series));
    AnalysisCriterion profit = new TotalProfitCriterion();
    assertEquals(0.95 * 0.7, profit.calculate(series, tradingRecord), TATestsUtils.TA_OFFSET);
}
Also used : MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

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