Search in sources :

Example 6 with SimpleMovingAverage

use of name.abuchen.portfolio.ui.views.SimpleMovingAverage in project portfolio by buchen.

the class SimpleMovingAverageTest method testSufficientPriceDataStartDate.

@Test
public void testSufficientPriceDataStartDate() {
    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);
    }
    LocalDate startDate = LocalDate.parse("2016-06-01");
    Date isStartDate = java.sql.Date.valueOf(startDate);
    ChartLineSeriesAxes SMALines = new SimpleMovingAverage(10, security, startDate).getSMA();
    assertThat(SMALines, is(IsNull.notNullValue()));
    assertThat(SMALines.getDates()[0], is(isStartDate));
}
Also used : ChartLineSeriesAxes(name.abuchen.portfolio.ui.views.ChartLineSeriesAxes) SimpleMovingAverage(name.abuchen.portfolio.ui.views.SimpleMovingAverage) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) Security(name.abuchen.portfolio.model.Security) LocalDate(java.time.LocalDate) Date(java.util.Date) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

ChartLineSeriesAxes (name.abuchen.portfolio.ui.views.ChartLineSeriesAxes)6 SimpleMovingAverage (name.abuchen.portfolio.ui.views.SimpleMovingAverage)6 Test (org.junit.Test)6 LocalDate (java.time.LocalDate)3 Security (name.abuchen.portfolio.model.Security)3 SecurityPrice (name.abuchen.portfolio.model.SecurityPrice)3 Date (java.util.Date)2