use of org.ta4j.core.mocks.MockBar 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);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class KeltnerChannelLowerIndicatorTest method setUp.
@Before
public void setUp() {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(11577.43, 11670.75, 11711.47, 11577.35));
bars.add(new MockBar(11670.90, 11691.18, 11698.22, 11635.74));
bars.add(new MockBar(11688.61, 11722.89, 11742.68, 11652.89));
bars.add(new MockBar(11716.93, 11697.31, 11736.74, 11667.46));
bars.add(new MockBar(11696.86, 11674.76, 11726.94, 11599.68));
bars.add(new MockBar(11672.34, 11637.45, 11677.33, 11573.87));
bars.add(new MockBar(11638.51, 11671.88, 11704.12, 11635.48));
bars.add(new MockBar(11673.62, 11755.44, 11782.23, 11673.62));
bars.add(new MockBar(11753.70, 11731.90, 11757.25, 11700.53));
bars.add(new MockBar(11732.13, 11787.38, 11794.15, 11698.83));
bars.add(new MockBar(11783.82, 11837.93, 11858.78, 11777.99));
bars.add(new MockBar(11834.21, 11825.29, 11861.24, 11798.46));
bars.add(new MockBar(11823.70, 11822.80, 11845.16, 11744.77));
bars.add(new MockBar(11822.95, 11871.84, 11905.48, 11822.80));
bars.add(new MockBar(11873.43, 11980.52, 11982.94, 11867.98));
bars.add(new MockBar(11980.52, 11977.19, 11985.97, 11898.74));
bars.add(new MockBar(11978.85, 11985.44, 12020.52, 11961.83));
bars.add(new MockBar(11985.36, 11989.83, 12019.53, 11971.93));
bars.add(new MockBar(11824.39, 11891.93, 11891.93, 11817.88));
bars.add(new MockBar(11892.50, 12040.16, 12050.75, 11892.50));
bars.add(new MockBar(12038.27, 12041.97, 12057.91, 12018.51));
bars.add(new MockBar(12040.68, 12062.26, 12080.54, 11981.05));
bars.add(new MockBar(12061.73, 12092.15, 12092.42, 12025.78));
bars.add(new MockBar(12092.38, 12161.63, 12188.76, 12092.30));
bars.add(new MockBar(12152.70, 12233.15, 12238.79, 12150.05));
bars.add(new MockBar(12229.29, 12239.89, 12254.23, 12188.19));
bars.add(new MockBar(12239.66, 12229.29, 12239.66, 12156.94));
bars.add(new MockBar(12227.78, 12273.26, 12285.94, 12180.48));
bars.add(new MockBar(12266.83, 12268.19, 12276.21, 12235.91));
bars.add(new MockBar(12266.75, 12226.64, 12267.66, 12193.27));
bars.add(new MockBar(12219.79, 12288.17, 12303.16, 12219.79));
bars.add(new MockBar(12287.72, 12318.14, 12331.31, 12253.24));
bars.add(new MockBar(12389.74, 12212.79, 12389.82, 12176.31));
data = new MockTimeSeries(bars);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class NVIIndicatorTest method getValue.
@Test
public void getValue() {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(1355.69, 2739.55));
bars.add(new MockBar(1325.51, 3119.46));
bars.add(new MockBar(1335.02, 3466.88));
bars.add(new MockBar(1313.72, 2577.12));
bars.add(new MockBar(1319.99, 2480.45));
bars.add(new MockBar(1331.85, 2329.79));
bars.add(new MockBar(1329.04, 2793.07));
bars.add(new MockBar(1362.16, 3378.78));
bars.add(new MockBar(1365.51, 2417.59));
bars.add(new MockBar(1374.02, 1442.81));
TimeSeries series = new MockTimeSeries(bars);
NVIIndicator nvi = new NVIIndicator(series);
assertDecimalEquals(nvi.getValue(0), 1000);
assertDecimalEquals(nvi.getValue(1), 1000);
assertDecimalEquals(nvi.getValue(2), 1000);
assertDecimalEquals(nvi.getValue(3), 984.0452);
assertDecimalEquals(nvi.getValue(4), 988.7417);
assertDecimalEquals(nvi.getValue(5), 997.6255);
assertDecimalEquals(nvi.getValue(6), 997.6255);
assertDecimalEquals(nvi.getValue(7), 997.6255);
assertDecimalEquals(nvi.getValue(8), 1000.079);
assertDecimalEquals(nvi.getValue(9), 1006.3116);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class OnBalanceVolumeIndicatorTest method getValue.
@Test
public void getValue() {
ZonedDateTime now = ZonedDateTime.now();
List<Bar> bars = new ArrayList<>();
bars.add(new MockBar(now, 0, 10, 0, 0, 0, 4, 0));
bars.add(new MockBar(now, 0, 5, 0, 0, 0, 2, 0));
bars.add(new MockBar(now, 0, 6, 0, 0, 0, 3, 0));
bars.add(new MockBar(now, 0, 7, 0, 0, 0, 8, 0));
bars.add(new MockBar(now, 0, 7, 0, 0, 0, 6, 0));
bars.add(new MockBar(now, 0, 6, 0, 0, 0, 10, 0));
OnBalanceVolumeIndicator obv = new OnBalanceVolumeIndicator(new MockTimeSeries(bars));
assertDecimalEquals(obv.getValue(0), 0);
assertDecimalEquals(obv.getValue(1), -2);
assertDecimalEquals(obv.getValue(2), 1);
assertDecimalEquals(obv.getValue(3), 9);
assertDecimalEquals(obv.getValue(4), 9);
assertDecimalEquals(obv.getValue(5), -1);
}
use of org.ta4j.core.mocks.MockBar in project ta4j by ta4j.
the class PVIIndicatorTest method getValue.
@Test
public void getValue() {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(1355.69, 2739.55));
bars.add(new MockBar(1325.51, 3119.46));
bars.add(new MockBar(1335.02, 3466.88));
bars.add(new MockBar(1313.72, 2577.12));
bars.add(new MockBar(1319.99, 2480.45));
bars.add(new MockBar(1331.85, 2329.79));
bars.add(new MockBar(1329.04, 2793.07));
bars.add(new MockBar(1362.16, 3378.78));
bars.add(new MockBar(1365.51, 2417.59));
bars.add(new MockBar(1374.02, 1442.81));
TimeSeries series = new MockTimeSeries(bars);
PVIIndicator pvi = new PVIIndicator(series);
assertDecimalEquals(pvi.getValue(0), 1000);
assertDecimalEquals(pvi.getValue(1), 977.7383);
assertDecimalEquals(pvi.getValue(2), 984.7532);
assertDecimalEquals(pvi.getValue(3), 984.7532);
assertDecimalEquals(pvi.getValue(4), 984.7532);
assertDecimalEquals(pvi.getValue(5), 984.7532);
assertDecimalEquals(pvi.getValue(6), 982.6755);
assertDecimalEquals(pvi.getValue(7), 1007.164);
assertDecimalEquals(pvi.getValue(8), 1007.164);
assertDecimalEquals(pvi.getValue(9), 1007.164);
}
Aggregations