Search in sources :

Example 11 with TimeSeries

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());
}
Also used : TimeSeries(org.ta4j.core.TimeSeries) BaseTimeSeries(org.ta4j.core.BaseTimeSeries)

Example 12 with TimeSeries

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);
}
Also used : TimeSeries(org.ta4j.core.TimeSeries) TimeSeriesManager(org.ta4j.core.TimeSeriesManager) Strategy(org.ta4j.core.Strategy) CCICorrectionStrategy(ta4jexamples.strategies.CCICorrectionStrategy)

Example 13 with TimeSeries

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());
    }
}
Also used : TimeSeries(org.ta4j.core.TimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Example 14 with TimeSeries

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);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) Bar(org.ta4j.core.Bar) TimeSeries(org.ta4j.core.TimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Example 15 with TimeSeries

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);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) Bar(org.ta4j.core.Bar) TimeSeries(org.ta4j.core.TimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) Test(org.junit.Test)

Aggregations

TimeSeries (org.ta4j.core.TimeSeries)48 MockTimeSeries (org.ta4j.core.mocks.MockTimeSeries)30 Test (org.junit.Test)24 ClosePriceIndicator (org.ta4j.core.indicators.helpers.ClosePriceIndicator)16 BaseTradingRecord (org.ta4j.core.BaseTradingRecord)12 TradingRecord (org.ta4j.core.TradingRecord)11 Bar (org.ta4j.core.Bar)9 Before (org.junit.Before)7 ArrayList (java.util.ArrayList)5 MockBar (org.ta4j.core.mocks.MockBar)5 BaseTimeSeries (org.ta4j.core.BaseTimeSeries)4 ZonedDateTime (java.time.ZonedDateTime)3 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)3 Strategy (org.ta4j.core.Strategy)3 BitfinexApiBroker (com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker)2 BitfinexCandlestickSymbol (com.github.jnidzwetzki.bitfinex.v2.entity.symbol.BitfinexCandlestickSymbol)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 JFreeChart (org.jfree.chart.JFreeChart)2 XYPlot (org.jfree.chart.plot.XYPlot)2 TimeSeriesManager (org.ta4j.core.TimeSeriesManager)2