use of org.ta4j.core.TimeSeries in project ta4j by ta4j.
the class CsvTradesLoader method main.
public static void main(String[] args) {
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
System.out.println("Series: " + series.getName() + " (" + series.getSeriesPeriodDescription() + ")");
System.out.println("Number of bars: " + series.getBarCount());
System.out.println("First bar: \n" + "\tVolume: " + series.getBar(0).getVolume() + "\n" + "\tNumber of trades: " + series.getBar(0).getTrades() + "\n" + "\tClose price: " + series.getBar(0).getClosePrice());
}
use of org.ta4j.core.TimeSeries in project ta4j by ta4j.
the class StrategyExecutionLogging method main.
public static void main(String[] args) {
// Loading the Logback configuration
loadLoggerConfiguration();
// Getting the time series
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
// Building the trading strategy
Strategy strategy = CCICorrectionStrategy.buildStrategy(series);
// Running the strategy
TimeSeriesManager seriesManager = new TimeSeriesManager(series);
seriesManager.run(strategy);
}
use of org.ta4j.core.TimeSeries in project ta4j by ta4j.
the class VolumeIndicatorTest method indicatorShouldRetrieveBarVolume.
@Test
public void indicatorShouldRetrieveBarVolume() {
TimeSeries series = new MockTimeSeries();
VolumeIndicator volumeIndicator = new VolumeIndicator(series);
for (int i = 0; i < 10; i++) {
assertEquals(volumeIndicator.getValue(i), series.getBar(i).getVolume());
}
}
use of org.ta4j.core.TimeSeries 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.TimeSeries 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