Package com.xeiam.xchange.virtex.v2.service.polling

Examples of com.xeiam.xchange.virtex.v2.service.polling.VirtExMarketDataService


  @Override
  public void applySpecification(ExchangeSpecification exchangeSpecification) {

    super.applySpecification(exchangeSpecification);
    this.pollingMarketDataService = new VirtExMarketDataService(exchangeSpecification);
  }
View Full Code Here


  }

  private static void raw(VirtExMarketDataServiceRaw marketDataService) throws IOException {

    // Get the latest order book data for BTC/CAD
    VirtExDepth orderBook = marketDataService.getVirtExOrderBook(CurrencyPair.BTC_CAD);

    System.out.println("Current Order Book size for BTC / CAD: " + (orderBook.getAsks().size() + orderBook.getBids().size()));

    System.out.println("Last Ask: " + orderBook.getAsks().get(0)[0].toString());

    System.out.println("Last Bid: " + orderBook.getBids().get(0)[0].toString());

    System.out.println(orderBook.toString());
  }
View Full Code Here

  @Override
  public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {

    // Request data
    VirtExDepth virtExDepth = getVirtExOrderBook(currencyPair);

    // Adapt to XChange DTOs
    List<LimitOrder> asks = VirtExAdapters.adaptOrders(virtExDepth.getAsks(), currencyPair, "ask", "");
    Collections.reverse(asks);
    List<LimitOrder> bids = VirtExAdapters.adaptOrders(virtExDepth.getBids(), currencyPair, "bid", "");

    return new OrderBook(null, asks, bids);
  }
View Full Code Here

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

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

    List<LimitOrder> asks = VirtExAdapters.adaptOrders(VirtExDepth.getDepth().getAsks(), CurrencyPair.BTC_CAD, "ask", "");

    // Verify all fields filled
    assertThat(asks.get(0).getLimitPrice().doubleValue()).isEqualTo(500000.000000000);
    assertThat(asks.get(0).getType()).isEqualTo(OrderType.ASK);
    assertThat(asks.get(0).getTradableAmount().doubleValue()).isEqualTo(7.000000000);
View Full Code Here

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

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

    // Verify that the example data was unmarshalled correctly
    assertThat(virtExDepth.getDepth().getAsks().get(0)[0]).isEqualTo(new BigDecimal("500000.000000000"));
  }
View Full Code Here

    InputStream is = VirtExTickerJSONTest.class.getResourceAsStream("/marketdata/example-ticker-data-v2.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    VirtExTickerWrapper virtExTickerWrapper = mapper.readValue(is, VirtExTickerWrapper.class);
    VirtExTicker virtExTicker = virtExTickerWrapper.getTicker();

    // Verify that the example data was unmarshalled correctly
    assertThat(virtExTicker.getLast()).isEqualTo(new BigDecimal("545.060000000"));
    assertThat(virtExTicker.getHigh()).isEqualTo(new BigDecimal("574.000000000"));
    assertThat(virtExTicker.getLow()).isEqualTo(new BigDecimal("538.000000000"));
    assertThat(virtExTicker.getVolume()).isEqualTo(new BigDecimal("284.231600000"));
    assertThat(virtExTicker.getSell()).isEqualTo(new BigDecimal("545.06000"));
    assertThat(virtExTicker.getBuy()).isEqualTo(new BigDecimal("545.03000"));

  }
View Full Code Here

  }

  private static void raw(VirtExMarketDataServiceRaw marketDataService) throws IOException {

    // Get the latest ticker data showing BTC to CAD
    VirtExTicker ticker = marketDataService.getVirtExTicker(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

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

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

    Ticker ticker = VirtExAdapters.adaptTicker(VirtExTicker.getTicker(), CurrencyPair.BTC_CAD);
    System.out.println(ticker.toString());

    assertThat(ticker.getLast().toString()).isEqualTo("545.060000000");
    assertThat(ticker.getLow().toString()).isEqualTo("538.000000000");
    assertThat(ticker.getHigh().toString()).isEqualTo("574.000000000");
View Full Code Here

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

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    VirtExTickerWrapper virtExTickerWrapper = mapper.readValue(is, VirtExTickerWrapper.class);
    VirtExTicker virtExTicker = virtExTickerWrapper.getTicker();

    // Verify that the example data was unmarshalled correctly
    assertThat(virtExTicker.getLast()).isEqualTo(new BigDecimal("545.060000000"));
    assertThat(virtExTicker.getHigh()).isEqualTo(new BigDecimal("574.000000000"));
    assertThat(virtExTicker.getLow()).isEqualTo(new BigDecimal("538.000000000"));
View Full Code Here

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

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

    Trades trades = VirtExAdapters.adaptTrades(VirtExTrades.getTrades(), CurrencyPair.BTC_CAD);
    assertThat(trades.getTrades().size()).isEqualTo(632);

    // Verify all fields filled
    assertThat(trades.getTrades().get(0).getPrice().doubleValue() == 545.060000000);
    assertThat(trades.getTrades().get(0).getTradableAmount().doubleValue() == 1.189100000);
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.virtex.v2.service.polling.VirtExMarketDataService

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.