Search in sources :

Example 6 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator 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 7 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator 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 8 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.

the class MeanDeviationIndicatorTest method meanDeviationShouldBeZeroWhenTimeFrameIs1.

@Test
public void meanDeviationShouldBeZeroWhenTimeFrameIs1() {
    MeanDeviationIndicator meanDeviation = new MeanDeviationIndicator(new ClosePriceIndicator(data), 1);
    assertDecimalEquals(meanDeviation.getValue(2), 0);
    assertDecimalEquals(meanDeviation.getValue(7), 0);
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 9 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator 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 10 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.

the class SigmaIndicatorTest method test.

@Test
public void test() {
    SigmaIndicator zScore = new SigmaIndicator(new ClosePriceIndicator(data), 5);
    assertDecimalEquals(zScore.getValue(1), 1.0);
    assertDecimalEquals(zScore.getValue(2), 1.224744871391589);
    assertDecimalEquals(zScore.getValue(3), 1.34164078649987387);
    assertDecimalEquals(zScore.getValue(4), 1.414213562373095);
    assertDecimalEquals(zScore.getValue(5), 1.414213562373095);
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Aggregations

ClosePriceIndicator (org.ta4j.core.indicators.helpers.ClosePriceIndicator)81 Test (org.junit.Test)55 MockTimeSeries (org.ta4j.core.mocks.MockTimeSeries)26 TimeSeries (org.ta4j.core.TimeSeries)16 Before (org.junit.Before)14 SMAIndicator (org.ta4j.core.indicators.SMAIndicator)7 OverIndicatorRule (org.ta4j.core.trading.rules.OverIndicatorRule)6 ArrayList (java.util.ArrayList)5 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)5 MockBar (org.ta4j.core.mocks.MockBar)5 UnderIndicatorRule (org.ta4j.core.trading.rules.UnderIndicatorRule)5 SimpleDateFormat (java.text.SimpleDateFormat)4 JFreeChart (org.jfree.chart.JFreeChart)4 DateAxis (org.jfree.chart.axis.DateAxis)4 XYPlot (org.jfree.chart.plot.XYPlot)4 EMAIndicator (org.ta4j.core.indicators.EMAIndicator)4 CrossedDownIndicatorRule (org.ta4j.core.trading.rules.CrossedDownIndicatorRule)4 BaseStrategy (org.ta4j.core.BaseStrategy)3 Decimal (org.ta4j.core.Decimal)3 MaxPriceIndicator (org.ta4j.core.indicators.helpers.MaxPriceIndicator)3