use of org.ta4j.core.TimeSeries in project ta4j by ta4j.
the class DoubleEMAIndicatorTest method setUp.
@Before
public void setUp() {
TimeSeries data = new MockTimeSeries(0.73, 0.72, 0.86, 0.72, 0.62, 0.76, 0.84, 0.69, 0.65, 0.71, 0.53, 0.73, 0.77, 0.67, 0.68);
closePrice = new ClosePriceIndicator(data);
}
use of org.ta4j.core.TimeSeries in project ta4j by ta4j.
the class PPOIndicatorTest method setUp.
@Before
public void setUp() {
TimeSeries series = new MockTimeSeries(22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23, 22.43, 22.24, 22.29, 22.15, 22.39, 22.38, 22.61, 23.36, 24.05, 23.75, 23.83, 23.95, 23.63, 23.82, 23.87, 23.65, 23.19, 23.10, 23.33, 22.68, 23.10, 21.40, 20.17);
closePriceIndicator = new ClosePriceIndicator(series);
}
use of org.ta4j.core.TimeSeries in project ta4j by ta4j.
the class BollingerBandsLowerIndicatorTest method setUp.
@Before
public void setUp() {
TimeSeries data = new MockTimeSeries(1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2);
timeFrame = 3;
closePrice = new ClosePriceIndicator(data);
sma = new SMAIndicator(closePrice, timeFrame);
}
use of org.ta4j.core.TimeSeries in project ta4j by ta4j.
the class AccumulationDistributionIndicatorTest method accumulationDistribution.
@Test
public void accumulationDistribution() {
ZonedDateTime now = ZonedDateTime.now();
List<Bar> bars = new ArrayList<>();
// 2-2 * 200 / 4
bars.add(new MockBar(now, 0d, 10d, 12d, 8d, 0d, 200d, 0));
// 1-2 *100 / 3
bars.add(new MockBar(now, 0d, 8d, 10d, 7d, 0d, 100d, 0));
// 3-6 *300 /9
bars.add(new MockBar(now, 0d, 9d, 15d, 6d, 0d, 300d, 0));
// 15-20 *50 / 35
bars.add(new MockBar(now, 0d, 20d, 40d, 5d, 0d, 50d, 0));
// 27-0 *600 /27
bars.add(new MockBar(now, 0d, 30d, 30d, 3d, 0d, 600d, 0));
TimeSeries series = new MockTimeSeries(bars);
AccumulationDistributionIndicator ac = new AccumulationDistributionIndicator(series);
assertDecimalEquals(ac.getValue(0), 0);
assertDecimalEquals(ac.getValue(1), -100d / 3);
assertDecimalEquals(ac.getValue(2), -100d - (100d / 3));
assertDecimalEquals(ac.getValue(3), (-250d / 35) + (-100d - (100d / 3)));
assertDecimalEquals(ac.getValue(4), 600d + ((-250d / 35) + (-100d - (100d / 3))));
}
use of org.ta4j.core.TimeSeries in project ta4j by ta4j.
the class ChaikinMoneyFlowIndicatorTest method getValue.
@Test
public void getValue() {
ZonedDateTime now = ZonedDateTime.now();
List<Bar> bars = new ArrayList<>();
bars.add(new BaseBar(now, "0", "62.34", "61.37", "62.15", "7849.025"));
bars.add(new BaseBar(now, "0", "62.05", "60.69", "60.81", "11692.075"));
bars.add(new BaseBar(now, "0", "62.27", "60.10", "60.45", "10575.307"));
bars.add(new BaseBar(now, "0", "60.79", "58.61", "59.18", "13059.128"));
bars.add(new BaseBar(now, "0", "59.93", "58.71", "59.24", "20733.508"));
bars.add(new BaseBar(now, "0", "61.75", "59.86", "60.20", "29630.096"));
bars.add(new BaseBar(now, "0", "60.00", "57.97", "58.48", "17705.294"));
bars.add(new BaseBar(now, "0", "59.00", "58.02", "58.24", "7259.203"));
bars.add(new BaseBar(now, "0", "59.07", "57.48", "58.69", "10474.629"));
bars.add(new BaseBar(now, "0", "59.22", "58.30", "58.65", "5203.714"));
bars.add(new BaseBar(now, "0", "58.75", "57.83", "58.47", "3422.865"));
bars.add(new BaseBar(now, "0", "58.65", "57.86", "58.02", "3962.150"));
bars.add(new BaseBar(now, "0", "58.47", "57.91", "58.17", "4095.905"));
bars.add(new BaseBar(now, "0", "58.25", "57.83", "58.07", "3766.006"));
bars.add(new BaseBar(now, "0", "58.35", "57.53", "58.13", "4239.335"));
bars.add(new BaseBar(now, "0", "59.86", "58.58", "58.94", "8039.979"));
bars.add(new BaseBar(now, "0", "59.53", "58.30", "59.10", "6956.717"));
bars.add(new BaseBar(now, "0", "62.10", "58.53", "61.92", "18171.552"));
bars.add(new BaseBar(now, "0", "62.16", "59.80", "61.37", "22225.894"));
bars.add(new BaseBar(now, "0", "62.67", "60.93", "61.68", "14613.509"));
bars.add(new BaseBar(now, "0", "62.38", "60.15", "62.09", "12319.763"));
bars.add(new BaseBar(now, "0", "63.73", "62.26", "62.89", "15007.690"));
bars.add(new BaseBar(now, "0", "63.85", "63.00", "63.53", "8879.667"));
bars.add(new BaseBar(now, "0", "66.15", "63.58", "64.01", "22693.812"));
bars.add(new BaseBar(now, "0", "65.34", "64.07", "64.77", "10191.814"));
bars.add(new BaseBar(now, "0", "66.48", "65.20", "65.22", "10074.152"));
bars.add(new BaseBar(now, "0", "65.23", "63.21", "63.28", "9411.620"));
bars.add(new BaseBar(now, "0", "63.40", "61.88", "62.40", "10391.690"));
bars.add(new BaseBar(now, "0", "63.18", "61.11", "61.55", "8926.512"));
bars.add(new BaseBar(now, "0", "62.70", "61.25", "62.69", "7459.575"));
TimeSeries series = new BaseTimeSeries(bars);
ChaikinMoneyFlowIndicator cmf = new ChaikinMoneyFlowIndicator(series, 20);
assertDecimalEquals(cmf.getValue(0), 0.6082);
assertDecimalEquals(cmf.getValue(1), -0.2484);
assertDecimalEquals(cmf.getValue(19), -0.1211);
assertDecimalEquals(cmf.getValue(20), -0.0997);
assertDecimalEquals(cmf.getValue(21), -0.0659);
assertDecimalEquals(cmf.getValue(22), -0.0257);
assertDecimalEquals(cmf.getValue(23), -0.0617);
assertDecimalEquals(cmf.getValue(24), -0.0481);
assertDecimalEquals(cmf.getValue(25), -0.0086);
assertDecimalEquals(cmf.getValue(26), -0.0087);
assertDecimalEquals(cmf.getValue(27), -0.005);
assertDecimalEquals(cmf.getValue(28), -0.0574);
assertDecimalEquals(cmf.getValue(29), -0.0148);
}
Aggregations