Search in sources :

Example 6 with Strategy

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

the class AbstractAnalysisCriterionTest method bestShouldBeBuyAndHoldOnLoss.

@Test
public void bestShouldBeBuyAndHoldOnLoss() {
    MockTimeSeries series = new MockTimeSeries(6.0, 3.0, 6.0, 6.0);
    TimeSeriesManager manager = new TimeSeriesManager(series);
    Strategy bestStrategy = new TotalProfitCriterion().chooseBest(manager, strategies);
    assertEquals(buyAndHoldStrategy, bestStrategy);
}
Also used : TimeSeriesManager(org.ta4j.core.TimeSeriesManager) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) BaseStrategy(org.ta4j.core.BaseStrategy) Strategy(org.ta4j.core.Strategy) Test(org.junit.Test)

Example 7 with Strategy

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

the class AbstractAnalysisCriterionTest method bestShouldBeAlwaysOperateOnProfit.

@Test
public void bestShouldBeAlwaysOperateOnProfit() {
    MockTimeSeries series = new MockTimeSeries(6.0, 9.0, 6.0, 6.0);
    TimeSeriesManager manager = new TimeSeriesManager(series);
    Strategy bestStrategy = new TotalProfitCriterion().chooseBest(manager, strategies);
    assertEquals(alwaysStrategy, bestStrategy);
}
Also used : TimeSeriesManager(org.ta4j.core.TimeSeriesManager) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) BaseStrategy(org.ta4j.core.BaseStrategy) Strategy(org.ta4j.core.Strategy) Test(org.junit.Test)

Aggregations

Strategy (org.ta4j.core.Strategy)7 BaseStrategy (org.ta4j.core.BaseStrategy)4 TimeSeriesManager (org.ta4j.core.TimeSeriesManager)4 Test (org.junit.Test)3 TimeSeries (org.ta4j.core.TimeSeries)3 MockTimeSeries (org.ta4j.core.mocks.MockTimeSeries)3 BitfinexCurrencyPair (com.github.jnidzwetzki.bitfinex.v2.entity.BitfinexCurrencyPair)1 EMAStrategy03 (com.github.jnidzwetzki.cryptobot.strategy.EMAStrategy03)1 TradeStrategyFactory (com.github.jnidzwetzki.cryptobot.strategy.TradeStrategyFactory)1 Before (org.junit.Before)1 TradingRecord (org.ta4j.core.TradingRecord)1 ClosePriceIndicator (org.ta4j.core.indicators.helpers.ClosePriceIndicator)1 FixedRule (org.ta4j.core.trading.rules.FixedRule)1 OverIndicatorRule (org.ta4j.core.trading.rules.OverIndicatorRule)1 UnderIndicatorRule (org.ta4j.core.trading.rules.UnderIndicatorRule)1 CCICorrectionStrategy (ta4jexamples.strategies.CCICorrectionStrategy)1 MovingMomentumStrategy (ta4jexamples.strategies.MovingMomentumStrategy)1