Search in sources :

Example 26 with TimeSeries

use of org.ta4j.core.TimeSeries in project ta4j by ta4j.

the class BollingerBandsUpperIndicatorTest 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);
}
Also used : SMAIndicator(org.ta4j.core.indicators.SMAIndicator) TimeSeries(org.ta4j.core.TimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Before(org.junit.Before)

Example 27 with TimeSeries

use of org.ta4j.core.TimeSeries in project ta4j by ta4j.

the class KAMAIndicatorTest method getValueOnDeepIndicesShouldNotCauseStackOverflow.

@Test
public void getValueOnDeepIndicesShouldNotCauseStackOverflow() {
    TimeSeries series = new MockTimeSeries();
    series.setMaximumBarCount(5000);
    assertEquals(5000, series.getBarCount());
    KAMAIndicator kama = new KAMAIndicator(new ClosePriceIndicator(series), 10, 2, 30);
    try {
        assertDecimalEquals(kama.getValue(3000), "2999.75");
    } catch (Throwable t) {
        fail(t.getMessage());
    }
}
Also used : TimeSeries(org.ta4j.core.TimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 28 with TimeSeries

use of org.ta4j.core.TimeSeries in project ta4j by ta4j.

the class PercentBIndicatorTest method setUp.

@Before
public void setUp() {
    TimeSeries data = new MockTimeSeries(10, 12, 15, 14, 17, 20, 21, 20, 20, 19, 20, 17, 12, 12, 9, 8, 9, 10, 9, 10);
    closePrice = new ClosePriceIndicator(data);
}
Also used : TimeSeries(org.ta4j.core.TimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Before(org.junit.Before)

Example 29 with TimeSeries

use of org.ta4j.core.TimeSeries in project crypto-bot by jnidzwetzki.

the class DonchianBot method getUpperChannelValue.

/**
 * Get the upper channel value
 * @param currencyPair
 * @return
 */
private Decimal getUpperChannelValue(final BitfinexCurrencyPair currencyPair) {
    final TimeSeries currencyTimeSeries = timeSeries.get(currencyPair);
    final MaxPriceIndicator maxPrice = new MaxPriceIndicator(currencyTimeSeries);
    final DonchianChannelUpper donchianChannelUpper = new DonchianChannelUpper(maxPrice, periodIn);
    return donchianChannelUpper.getValue(currencyTimeSeries.getEndIndex());
}
Also used : MaxPriceIndicator(org.ta4j.core.indicators.helpers.MaxPriceIndicator) TimeSeries(org.ta4j.core.TimeSeries) DonchianChannelUpper(com.github.jnidzwetzki.cryptobot.strategy.indicator.DonchianChannelUpper)

Example 30 with TimeSeries

use of org.ta4j.core.TimeSeries in project crypto-bot by jnidzwetzki.

the class DonchianBot method getLowerChannelValue.

/**
 * Get the lower channel value
 * @param currencyPair
 * @return
 */
private Decimal getLowerChannelValue(final BitfinexCurrencyPair currencyPair) {
    final TimeSeries currencyTimeSeries = timeSeries.get(currencyPair);
    final MinPriceIndicator minPrice = new MinPriceIndicator(currencyTimeSeries);
    final DonchianChannelLower donchianChannelLower = new DonchianChannelLower(minPrice, periodOut);
    return donchianChannelLower.getValue(currencyTimeSeries.getEndIndex());
}
Also used : TimeSeries(org.ta4j.core.TimeSeries) DonchianChannelLower(com.github.jnidzwetzki.cryptobot.strategy.indicator.DonchianChannelLower) MinPriceIndicator(org.ta4j.core.indicators.helpers.MinPriceIndicator)

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