use of name.abuchen.portfolio.ui.views.ChartLineSeriesAxes in project portfolio by buchen.
the class SimpleMovingAverageTest method testSecurityHasOnlyOnePrice.
@Test
public void testSecurityHasOnlyOnePrice() {
ChartLineSeriesAxes SMALines = new SimpleMovingAverage(200, this.securityOnePrice, null).getSMA();
assertThat(SMALines.getDates(), is(IsNull.nullValue()));
}
use of name.abuchen.portfolio.ui.views.ChartLineSeriesAxes in project portfolio by buchen.
the class SimpleMovingAverageTest method testCorrectSMAEntries.
@Test
public void testCorrectSMAEntries() {
ChartLineSeriesAxes SMALines = new SimpleMovingAverage(10, this.securityTenPrices, null).getSMA();
assertThat(SMALines, is(IsNull.notNullValue()));
assertThat(SMALines.getValues().length, is(1));
assertThat(SMALines.getValues()[0], is((1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) / Values.Quote.divider() / 10));
}
use of name.abuchen.portfolio.ui.views.ChartLineSeriesAxes in project portfolio by buchen.
the class SimpleMovingAverageTest method testSecurityIsNull.
@Test
public void testSecurityIsNull() {
ChartLineSeriesAxes SMALines = new SimpleMovingAverage(200, null, null).getSMA();
assertThat(SMALines.getDates(), is(IsNull.nullValue()));
}
use of name.abuchen.portfolio.ui.views.ChartLineSeriesAxes in project portfolio by buchen.
the class SimpleMovingAverageTest method testSufficientPriceDataPass.
@Test
public void testSufficientPriceDataPass() {
Security security = new Security();
LocalDate date = LocalDate.parse("2016-01-01");
for (int ii = 0; ii < 300; ii++) {
security.addPrice(new SecurityPrice(date, Values.Quote.factorize(10)));
date = date.plusDays(1);
}
ChartLineSeriesAxes SMALines = new SimpleMovingAverage(10, security, null).getSMA();
assertThat(SMALines, is(IsNull.notNullValue()));
assertThat(SMALines.getValues().length, is(security.getPrices().size() - 10 + 1));
}
use of name.abuchen.portfolio.ui.views.ChartLineSeriesAxes in project portfolio by buchen.
the class SimpleMovingAverageTest method testSecurityHasSparsePrice.
@Test
public void testSecurityHasSparsePrice() {
Security security = new Security();
LocalDate date = LocalDate.parse("2016-01-01");
for (int ii = 0; ii < 100; ii++) {
security.addPrice(new SecurityPrice(date, Values.Quote.factorize(10)));
date = date.plusDays(1);
}
security.addPrice(new SecurityPrice(LocalDate.parse("2017-01-01"), Values.Quote.factorize(12)));
LocalDate tmp = LocalDate.parse("2016-01-01");
tmp = tmp.plusDays(99);
Date lastSMADate = java.sql.Date.valueOf(tmp);
ChartLineSeriesAxes SMALines = new SimpleMovingAverage(10, security, null).getSMA();
assertThat(SMALines.getDates(), is(IsNull.notNullValue()));
assertThat(SMALines.getDates()[SMALines.getDates().length - 1], is(lastSMADate));
}
Aggregations