Package com.xeiam.xchange.dto.marketdata

Examples of com.xeiam.xchange.dto.marketdata.Ticker$Builder


    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    CryptoTradeTicker cryptoTradeTicker = mapper.readValue(is, CryptoTradeTicker.class);

    Ticker adaptedTicker = CryptoTradeAdapters.adaptTicker(CurrencyPair.BTC_USD, cryptoTradeTicker);

    assertThat(adaptedTicker.getLast()).isEqualTo(new BigDecimal("128"));
    assertThat(adaptedTicker.getLow()).isEqualTo(new BigDecimal("127.9999"));
    assertThat(adaptedTicker.getHigh()).isEqualTo(new BigDecimal("129.1"));
    assertThat(adaptedTicker.getVolume()).isEqualTo("5.4");
    assertThat(adaptedTicker.getAsk()).isEqualTo(new BigDecimal("129.1"));
    assertThat(adaptedTicker.getBid()).isEqualTo(new BigDecimal("128"));
    assertThat(adaptedTicker.getCurrencyPair().baseSymbol).isEqualTo(Currencies.BTC);
    assertThat(adaptedTicker.getTimestamp()).isNull();
  }
View Full Code Here


    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    BitcoiniumTicker BitcoiniumTicker = mapper.readValue(is, BitcoiniumTicker.class);

    Ticker ticker = BitcoiniumAdapters.adaptTicker(BitcoiniumTicker, CurrencyPair.BTC_USD);
    System.out.println(ticker.toString());

    assertThat(ticker.getLast()).isEqualTo(new BigDecimal("516.8"));
    assertThat(ticker.getLow().toString()).isEqualTo("508.28");
    assertThat(ticker.getHigh().toString()).isEqualTo("523.09");
    assertThat(ticker.getVolume()).isEqualTo(new BigDecimal("3522"));

  }
View Full Code Here

  }

  @Test
  public void testAdaptTicker() throws IOException, InvalidMessage, FieldNotFound {

    Ticker ticker = getTicker();

    assertEquals(CurrencyPair.BTC_CNY, ticker.getCurrencyPair());
    assertEquals(1413472045000L, ticker.getTimestamp().getTime());
    assertEquals(new BigDecimal("2328.08"), ticker.getBid());
    assertEquals(new BigDecimal("2329.14"), ticker.getAsk());
    assertEquals(new BigDecimal("2328.09"), ticker.getLast());
    assertEquals(new BigDecimal("2447.87"), ticker.getHigh());
    assertEquals(new BigDecimal("2316"), ticker.getLow());
    assertEquals(new BigDecimal("56083.6739"), ticker.getVolume());
  }
View Full Code Here

  }

  @Test
  public void testAdaptUpdate() throws IOException, InvalidMessage, FieldNotFound {

    Ticker oldTicker = getTicker();

    String messageData = getMessageData("X.txt");

    MarketDataIncrementalRefresh message = new MarketDataIncrementalRefresh();
    message.fromString(messageData, dataDictionary, true);

    log.debug(message.toXML(dataDictionary));

    Ticker ticker = BTCChinaFIXAdapters.adaptUpdate(oldTicker, message);

    assertEquals(CurrencyPair.BTC_CNY, ticker.getCurrencyPair());
    assertEquals(1413482716000L, ticker.getTimestamp().getTime());
    assertEquals(new BigDecimal("2328.08"), ticker.getBid());
    assertEquals(new BigDecimal("2325.53"), ticker.getAsk());
    assertEquals(new BigDecimal("2328.09"), ticker.getLast());
    assertEquals(new BigDecimal("2447.87"), ticker.getHigh());
    assertEquals(new BigDecimal("2316"), ticker.getLow());
    assertEquals(new BigDecimal("53826.1999"), ticker.getVolume());

  }
View Full Code Here

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    BTCChinaTicker BTCChinaTicker = mapper.readValue(is, BTCChinaTicker.class);

    Ticker ticker = BTCChinaAdapters.adaptTicker(BTCChinaTicker, CurrencyPair.BTC_CNY);
    System.out.println(ticker.toString());

    assertThat(ticker.getLast().toString()).isEqualTo("546.00");
    assertThat(ticker.getLow().toString()).isEqualTo("545.00");
    assertThat(ticker.getHigh().toString()).isEqualTo("547.77");
    assertThat(ticker.getVolume()).isEqualTo(new BigDecimal("2593.89900000"));

  }
View Full Code Here

    Map<CurrencyPair, Ticker> tickers = BTCChinaAdapters.adaptTickers(btcChinaTicker);
    assertEquals(3, tickers.size());

    assertEquals(new HashSet<CurrencyPair>(Arrays.asList(CurrencyPair.BTC_CNY, CurrencyPair.LTC_CNY, CurrencyPair.LTC_BTC)), tickers.keySet());

    Ticker btccny = tickers.get(CurrencyPair.BTC_CNY);
    assertEquals(new BigDecimal("2894.97"), btccny.getHigh());
    assertEquals(new BigDecimal("2850.08"), btccny.getLow());
    assertEquals(new BigDecimal("2880.00"), btccny.getBid());
    assertEquals(new BigDecimal("2883.86"), btccny.getAsk());
    assertEquals(new BigDecimal("2880.00"), btccny.getLast());
    assertEquals(new BigDecimal("4164.41040000"), btccny.getVolume());
    assertEquals(1396412841000L, btccny.getTimestamp().getTime());
  }
View Full Code Here

    MarketDataSnapshotFullRefresh message = new MarketDataSnapshotFullRefresh();
    message.fromString(messageData, dataDictionary, true);

    log.debug(message.toXML(dataDictionary));

    Ticker ticker = BTCChinaFIXAdapters.adaptTicker(message);
    return ticker;
  }
View Full Code Here

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    ANXTicker anxTicker = mapper.readValue(is, ANXTicker.class);

    Ticker ticker = ANXAdapters.adaptTicker(anxTicker);

    Assert.assertEquals(new BigDecimal("725.38123"), ticker.getLast());
    Assert.assertEquals(new BigDecimal("725.38123"), ticker.getHigh());
    Assert.assertEquals(new BigDecimal("380.00000"), ticker.getLow());
    Assert.assertEquals(new BigDecimal("7.00000000"), ticker.getVolume());
    Assert.assertEquals(new BigDecimal("725.38123"), ticker.getLast());
    Assert.assertEquals(new BigDecimal("38.85148"), ticker.getBid());
    Assert.assertEquals(new BigDecimal("897.25596"), ticker.getAsk());

    Assert.assertEquals(new Date(1393388594814L), ticker.getTimestamp());
  }
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();
    BTCETickerWrapper bTCETickerWrapper = mapper.readValue(is, BTCETickerWrapper.class);

    // Verify that the example data was unmarshalled correctly
    assertThat(bTCETickerWrapper.getTicker(BTCEUtils.getPair(CurrencyPair.BTC_USD)).getLast()).isEqualTo(new BigDecimal("757"));
    Ticker ticker = BTCEAdapters.adaptTicker(bTCETickerWrapper.getTicker(BTCEUtils.getPair(CurrencyPair.BTC_USD)), CurrencyPair.BTC_USD);

    assertThat(ticker.getLast().toString()).isEqualTo("757");
    assertThat(ticker.getLow().toString()).isEqualTo("655");
    assertThat(ticker.getHigh().toString()).isEqualTo("770");
    assertThat(ticker.getVolume()).isEqualTo(new BigDecimal("24620.6561"));
    assertThat(DateUtils.toUTCString(ticker.getTimestamp())).isEqualTo("2013-11-23 11:13:39 GMT");

  }
View Full Code Here

  }

  private static void generic(PollingMarketDataService marketDataService) throws IOException {

    // Get the latest ticker data showing BTC to CAD
    Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_CAD);

    System.out.println("Currency: " + Currencies.CAD);
    System.out.println("Last: " + ticker.getLast().toString());
    System.out.println("Volume: " + ticker.getVolume().toString());
    System.out.println("High: " + ticker.getHigh().toString());
    System.out.println("Low: " + ticker.getLow().toString());
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.dto.marketdata.Ticker$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.