コード例 #1
0
ファイル: CSVReaderTest.java プロジェクト: Almaz-KG/Germes
  public void checkAAPL(QuoteHistory quoteHistory) {
    String stockName = quoteHistory.getQuote().toString();
    Assert.assertNotNull(stockName);
    Assert.assertFalse(stockName.isEmpty());
    Assert.assertFalse(stockName.startsWith("#"));
    Assert.assertEquals(stockName, "AAPL");

    Assert.assertEquals(TimeFrame.Hour1, quoteHistory.getTimeFrame());

    Bar bar = quoteHistory.getHistory().get(0);

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(bar.getDate());

    Assert.assertEquals(2014, calendar.get(Calendar.YEAR));
    Assert.assertEquals(7, calendar.get(Calendar.MONTH));
    Assert.assertEquals(22, calendar.get(Calendar.DAY_OF_MONTH));
    Assert.assertEquals(19, calendar.get(Calendar.HOUR_OF_DAY));
    Assert.assertEquals(0, calendar.get(Calendar.MINUTE));

    Assert.assertEquals(101.2, bar.getOpen());
    Assert.assertEquals(101.32, bar.getHigh());
    Assert.assertEquals(101.03, bar.getLow());
    Assert.assertEquals(101.17, bar.getClose());
    Assert.assertEquals(508.0, bar.getValue());
  }
コード例 #2
0
ファイル: CSVReaderTest.java プロジェクト: Almaz-KG/Germes
  @Test
  public void testReadGZP() throws IOException, ParseException, QuoteException {
    QuoteHistory quoteHistory =
        new CSVReader().read(GZP_RESOURCE_FILE, Quotes.GAZP, TimeFrame.Hour1);
    Assert.assertEquals(quoteHistory.getHistory().size(), 3);

    String stockName = quoteHistory.getQuote().toString();
    Assert.assertNotNull(stockName);
    Assert.assertFalse(stockName.isEmpty());
    Assert.assertFalse(stockName.startsWith("#"));
    Assert.assertEquals(stockName, "GAZP");

    Assert.assertEquals(TimeFrame.Hour1, quoteHistory.getTimeFrame());

    Bar bar = quoteHistory.getHistory().get(0);

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(bar.getDate());

    Assert.assertEquals(2014, calendar.get(Calendar.YEAR));
    Assert.assertEquals(7, calendar.get(Calendar.MONTH));
    Assert.assertEquals(22, calendar.get(Calendar.DAY_OF_MONTH));
    Assert.assertEquals(14, calendar.get(Calendar.HOUR_OF_DAY));
    Assert.assertEquals(0, calendar.get(Calendar.MINUTE));

    Assert.assertEquals(134.26, bar.getOpen());
    Assert.assertEquals(134.60, bar.getHigh());
    Assert.assertEquals(134.05, bar.getLow());
    Assert.assertEquals(134.53, bar.getClose());
    Assert.assertEquals(377.0, bar.getValue());
  }
コード例 #3
0
ファイル: CSVReaderTest.java プロジェクト: Almaz-KG/Germes
  @Test
  public void testReadGold() throws IOException, ParseException, QuoteException {
    QuoteHistory quoteHistory =
        new CSVReader().read(GOLD_RESOURCE_FILE, Quotes.XAUUSD, TimeFrame.Day1);
    Assert.assertEquals(quoteHistory.getHistory().size(), 6);

    String stockName = quoteHistory.getQuote().toString();
    Assert.assertNotNull(stockName);
    Assert.assertFalse(stockName.isEmpty());
    Assert.assertFalse(stockName.startsWith("#"));
    Assert.assertEquals(stockName, "XAUUSD");

    Assert.assertEquals(TimeFrame.Day1, quoteHistory.getTimeFrame());

    Bar bar = quoteHistory.getHistory().get(0);

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(bar.getDate());

    // 2015.09.23,00:00,1124.330,1134.270,1121.840,1130.095,73175
    Assert.assertEquals(2015, calendar.get(Calendar.YEAR));
    Assert.assertEquals(8, calendar.get(Calendar.MONTH));
    Assert.assertEquals(23, calendar.get(Calendar.DAY_OF_MONTH));
    Assert.assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
    Assert.assertEquals(0, calendar.get(Calendar.MINUTE));

    Assert.assertEquals(1124.33, bar.getOpen());
    Assert.assertEquals(1134.27, bar.getHigh());
    Assert.assertEquals(1121.84, bar.getLow());
    Assert.assertEquals(1130.095, bar.getClose());
    Assert.assertEquals(73175.0, bar.getValue());
  }