use of org.ta4j.core.mocks.MockTimeSeries in project ta4j by ta4j.
the class MaxPriceIndicatorTest method setUp.
@Before
public void setUp() {
timeSeries = new MockTimeSeries();
maxPriceIndicator = new MaxPriceIndicator(timeSeries);
}
use of org.ta4j.core.mocks.MockTimeSeries in project ta4j by ta4j.
the class MedianPriceIndicatorTest method setUp.
@Before
public void setUp() {
List<Bar> bars = new ArrayList<Bar>();
bars.add(new MockBar(0, 0, 16, 8));
bars.add(new MockBar(0, 0, 12, 6));
bars.add(new MockBar(0, 0, 18, 14));
bars.add(new MockBar(0, 0, 10, 6));
bars.add(new MockBar(0, 0, 32, 6));
bars.add(new MockBar(0, 0, 2, 2));
bars.add(new MockBar(0, 0, 0, 0));
bars.add(new MockBar(0, 0, 8, 1));
bars.add(new MockBar(0, 0, 83, 32));
bars.add(new MockBar(0, 0, 9, 3));
this.timeSeries = new MockTimeSeries(bars);
average = new MedianPriceIndicator(timeSeries);
}
use of org.ta4j.core.mocks.MockTimeSeries in project ta4j by ta4j.
the class OpenPriceIndicatorTest method setUp.
@Before
public void setUp() {
timeSeries = new MockTimeSeries();
openPriceIndicator = new OpenPriceIndicator(timeSeries);
}
use of org.ta4j.core.mocks.MockTimeSeries in project ta4j by ta4j.
the class RewardRiskRatioCriterionTest method rewardRiskRatioCriterionOnlyWithGain.
@Test
public void rewardRiskRatioCriterionOnlyWithGain() {
MockTimeSeries series = new MockTimeSeries(1, 2, 3, 6, 8, 20, 3);
TradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, series), Order.sellAt(1, series), Order.buyAt(2, series), Order.sellAt(5, series));
assertTrue(Double.isInfinite(rrc.calculate(series, tradingRecord)));
}
use of org.ta4j.core.mocks.MockTimeSeries in project ta4j by ta4j.
the class TotalProfitCriterionTest method calculateOnlyWithLossTrades.
@Test
public void calculateOnlyWithLossTrades() {
MockTimeSeries series = new MockTimeSeries(100, 95, 100, 80, 85, 70);
TradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, series), Order.sellAt(1, series), Order.buyAt(2, series), Order.sellAt(5, series));
AnalysisCriterion profit = new TotalProfitCriterion();
assertEquals(0.95 * 0.7, profit.calculate(series, tradingRecord), TATestsUtils.TA_OFFSET);
}
Aggregations