Package com.xeiam.xchange.anx.v2.dto.marketdata

Examples of com.xeiam.xchange.anx.v2.dto.marketdata.ANXDepthWrapper


  }

  public ANXWithdrawalResponse anxWithdrawFunds(String currency, BigDecimal amount, String address) throws IOException {

    try {
      ANXWithdrawalResponseWrapper anxWithdrawalResponseWrapper =
          anxV2.withdrawBtc(exchangeSpecification.getApiKey(), signatureCreator, getNonce(), currency, address, amount.multiply(new BigDecimal(ANXUtils.BTC_VOLUME_AND_AMOUNT_INT_2_DECIMAL_FACTOR_2))
              .intValue(), 1, false, false);
      return anxWithdrawalResponseWrapper.getAnxWithdrawalResponse();
    } catch (ANXException e) {
      throw new ExchangeException("Error calling withdrawFunds(): " + e.getError(), e);
    }
  }
View Full Code Here


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

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

    // Verify that the example data was unmarshalled correctly
    // assertThat(anxFullDepth.getAsks().get(0).getAmountInt()).isEqualTo(727610000L);

    Assert.assertEquals(new Long(1392693096241000L), anxFullDepth.getMicroTime());
    Assert.assertEquals(3, anxFullDepth.getAsks().size());
    Assert.assertEquals(new BigDecimal("3260.40000"), anxFullDepth.getAsks().get(0).getPrice());
    Assert.assertEquals(326040000L, anxFullDepth.getAsks().get(0).getPriceInt());
    Assert.assertEquals(new BigDecimal("16.00000000"), anxFullDepth.getAsks().get(0).getAmount());
    Assert.assertEquals(1600000000L, anxFullDepth.getAsks().get(0).getAmountInt());

    Assert.assertEquals(4, anxFullDepth.getBids().size());
    Assert.assertEquals(new BigDecimal("2000.00000"), anxFullDepth.getBids().get(0).getPrice());
    Assert.assertEquals(200000000L, anxFullDepth.getBids().get(0).getPriceInt());
    Assert.assertEquals(new BigDecimal("3.00000000"), anxFullDepth.getBids().get(0).getAmount());
    Assert.assertEquals(300000000L, anxFullDepth.getBids().get(0).getAmountInt());

  }
View Full Code Here

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

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

    List<LimitOrder> asks = ANXAdapters.adaptOrders(anxDepth.getAsks(), "BTC", "USD", "ask", "id_567");
    Assert.assertEquals(3, asks.size());

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

  }

  public ANXDepthWrapper getANXFullOrderBook(CurrencyPair currencyPair) throws IOException {

    try {
      ANXDepthWrapper anxDepthWrapper = anxV2.getFullDepth(currencyPair.baseSymbol, currencyPair.counterSymbol);
      return anxDepthWrapper;
    } catch (ANXException e) {
      throw new ExchangeException("Error calling getANXFullOrderBook(): " + e.getError(), e);
    }
  }
View Full Code Here

    if (pathCurrencyPair == null) {
      return null;
    }
    try {
      if (i == 2) {
        ANXDepthWrapper anxDepthWrapper = getANXFullOrderBook(pathCurrencyPair);
        Map<String, ANXDepth> book = new HashMap<String, ANXDepth>();
        book.put(pathCurrencyPair.baseSymbol + pathCurrencyPair.counterSymbol, anxDepthWrapper.getAnxDepth());
        return book;
      }
      ANXDepthsWrapper anxDepthWrapper = anxV2.getFullDepths(pathCurrencyPair.baseSymbol, pathCurrencyPair.counterSymbol, extraCurrencyPairs.toString());
      return anxDepthWrapper.getAnxDepths();
    } catch (ANXException e) {
      throw new ExchangeException("Error calling getANXFullOrderBook(): " + e.getError(), e);
    }
  }
View Full Code Here

  }

  public ANXDepthWrapper getANXPartialOrderBook(CurrencyPair currencyPair) throws IOException {

    try {
      ANXDepthWrapper anxDepthWrapper = anxV2.getPartialDepth(currencyPair.baseSymbol, currencyPair.counterSymbol);
      return anxDepthWrapper;
    } catch (ANXException e) {
      throw new ExchangeException("Error calling getANXPartialOrderBook(): " + e.getError(), e);
    }
  }
View Full Code Here

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

    // Request data
    ANXDepthWrapper anxDepthWrapper = null;
    if (args.length > 0) {
      if (args[0] instanceof String) {
        if ("full" == args[0]) {
          anxDepthWrapper = getANXFullOrderBook(currencyPair);
        }
        else {
          anxDepthWrapper = getANXPartialOrderBook(currencyPair);
        }
      }
      else {
        throw new ExchangeException("Orderbook type argument must be a String!");
      }
    }
    else { // default to full orderbook
      anxDepthWrapper = getANXFullOrderBook(currencyPair);
    }

    // Adapt to XChange DTOs
    List<LimitOrder> asks = ANXAdapters.adaptOrders(anxDepthWrapper.getAnxDepth().getAsks(), currencyPair.baseSymbol, currencyPair.counterSymbol, "ask", "");
    List<LimitOrder> bids = ANXAdapters.adaptOrders(anxDepthWrapper.getAnxDepth().getBids(), currencyPair.baseSymbol, currencyPair.counterSymbol, "bid", "");
    Date date = new Date(anxDepthWrapper.getAnxDepth().getMicroTime() / 1000);
    return new OrderBook(date, asks, bids);
  }
View Full Code Here

        ANXDepthWrapper anxDepthWrapper = getANXFullOrderBook(pathCurrencyPair);
        Map<String, ANXDepth> book = new HashMap<String, ANXDepth>();
        book.put(pathCurrencyPair.baseSymbol + pathCurrencyPair.counterSymbol, anxDepthWrapper.getAnxDepth());
        return book;
      }
      ANXDepthsWrapper anxDepthWrapper = anxV2.getFullDepths(pathCurrencyPair.baseSymbol, pathCurrencyPair.counterSymbol, extraCurrencyPairs.toString());
      return anxDepthWrapper.getAnxDepths();
    } catch (ANXException e) {
      throw new ExchangeException("Error calling getANXFullOrderBook(): " + e.getError(), e);
    }
  }
View Full Code Here

    if (pathCurrencyPair == null) {
      return null;
    }
    try {
      if (i == 2) {
        ANXTicker anxTicker = getANXTicker(pathCurrencyPair);
        Map<String, ANXTicker> ticker = new HashMap<String, ANXTicker>();
        ticker.put(pathCurrencyPair.baseSymbol + pathCurrencyPair.counterSymbol, anxTicker);
        return ticker;
      }
      ANXTickersWrapper anxTickerWrapper = anxV2.getTickers(pathCurrencyPair.baseSymbol, pathCurrencyPair.counterSymbol, extraCurrencyPairs.toString());
View Full Code Here

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

    // 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());
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.anx.v2.dto.marketdata.ANXDepthWrapper

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.