예제 #1
0
  private static void generic(Long now, PollingMarketDataService marketDataService)
      throws IOException {

    // Get the latest trade data for BTC/BRL
    Trades trades = marketDataService.getTrades(CurrencyPair.BTC_BRL);
    System.out.println("Trades, default. Size= " + trades.getTrades().size());

    trades = marketDataService.getTrades(CurrencyPair.BTC_BRL, now - (24L * 60L * 60L * 1000L));
    System.out.println("Trades, last 24h= " + trades.getTrades().size());
  }
예제 #2
0
  @Test
  public void testTradeAdapter() throws IOException {

    // Read in the JSON from the example resources
    InputStream is =
        MtGoxAdapterTest.class.getResourceAsStream("/v0/marketdata/example-trades-data-v0.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    MtGoxTrades[] mtGoxTrades = mapper.readValue(is, MtGoxTrades[].class);

    Trades trades = MtGoxAdapters.adaptTrades(mtGoxTrades);
    System.out.println(trades.getTrades().size());
    assertTrue("Trades size should be 609", trades.getTrades().size() == 609);

    // verify all fields filled
    // System.out.println(trades.getTrades().get(0).toString());
    assertTrue(
        "Price should be 16.75",
        trades.getTrades().get(0).getPrice().getAmount().doubleValue() == 16.75);
    assertTrue("Order type should be Bid", trades.getTrades().get(0).getType() == OrderType.BID);
    assertTrue(
        "TradableAmount should be 0.09910328",
        trades.getTrades().get(0).getTradableAmount().doubleValue() == 0.09910328);
    assertTrue(
        "TradableIdentifier should be BTC",
        trades.getTrades().get(0).getTradableIdentifier().equals("BTC"));
    assertTrue(
        "TransactionCurrency should be USD",
        trades.getTrades().get(0).getTransactionCurrency().equals("USD"));
    // Unix 1358803625 = Mon, 21 Jan 2013 21:27:05 GMT
    assertThat(
        "2013-01-21 21:27:05 GMT",
        is(equalTo(DateUtils.toUTCString(trades.getTrades().get(0).getTimestamp()))));
  }
예제 #3
0
  @Test
  public void testTradeAdapter() throws IOException {

    // Read in the JSON from the example resources
    InputStream is =
        BitcurexTradesJSONTest.class.getResourceAsStream("/marketdata/example-trades-data.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    BitcurexTrade[] BitcurexTrades = mapper.readValue(is, BitcurexTrade[].class);

    Trades trades = BitcurexAdapters.adaptTrades(BitcurexTrades, CurrencyPair.BTC_EUR);
    assertThat(trades.getTrades().size()).isEqualTo(70);

    // Verify all fields filled
    assertThat(trades.getTrades().get(0).getPrice().doubleValue() == 70.00000000);
    assertThat(trades.getTrades().get(0).getTradableAmount().doubleValue() == 23.99500000);
    assertThat(DateUtils.toUTCString(trades.getTrades().get(0).getTimestamp()))
        .isEqualTo("2013-07-29 16:53:28 GMT");
  }