Package com.xeiam.xchange.campbx.dto.trade

Examples of com.xeiam.xchange.campbx.dto.trade.MyOpenOrders


    this.campbx = RestProxyFactory.createProxy(CampBX.class, exchangeSpecification.getSslUri());
  }

  public MyOpenOrders getCampBXOpenOrders() throws IOException {

    MyOpenOrders myOpenOrders = campbx.getOpenOrders(exchangeSpecification.getUserName(), exchangeSpecification.getPassword());

    return myOpenOrders;
  }
View Full Code Here


public class MyOrdersJSONTest {

  @Test
  public void testUnmarshal() throws IOException {

    MyOpenOrders orderBook = new ObjectMapper().readValue(MyOrdersJSONTest.class.getResourceAsStream("/trade/open-orders.json"), MyOpenOrders.class);

    // Verify that the example data was unmarshalled correctly
    List<CampBXOrder> buy = orderBook.getBuy();
    assertThat(buy.size()).isEqualTo(1);
    assertThat(buy.get(0).getInfo()).isNotNull();
    assertThat(buy.get(0).getPrice()).isNull();

    List<CampBXOrder> sell = orderBook.getSell();
    CampBXOrder order = sell.get(0);
    assertThat(order.getPrice()).isEqualTo(new BigDecimal("110.00"));
    assertThat(order.getOrderID()).isEqualTo("599254");
    assertThat(order.getQuantity()).isEqualTo(new BigDecimal("0.10000000"));
    assertThat(order.getDarkPool()).isFalse();
View Full Code Here

  }

  @Override
  public OpenOrders getOpenOrders() throws IOException {

    MyOpenOrders myOpenOrders = getCampBXOpenOrders();
    logger.debug("myOpenOrders = {}", myOpenOrders);

    if (!myOpenOrders.isError()) {

      // TODO move to adapter class
      List<LimitOrder> orders = new ArrayList<LimitOrder>();
      for (CampBXOrder cbo : myOpenOrders.getBuy()) {
        if (cbo.isError() || cbo.isInfo()) {
          logger.debug("Skipping non-order in Buy: " + cbo);
        }
        else {
          String id = composeOrderId(CampBX.OrderType.Buy, cbo.getOrderID());
          BigDecimal price = cbo.getPrice();
          orders.add(new LimitOrder(Order.OrderType.BID, cbo.getQuantity(), CurrencyPair.BTC_USD, id, cbo.getOrderEntered(), price));
        }
      }
      for (CampBXOrder cbo : myOpenOrders.getSell()) {
        if (cbo.isError() || cbo.isInfo()) {
          logger.debug("Skipping non-order in Sell: " + cbo);
        }
        else {

          String id = composeOrderId(CampBX.OrderType.Sell, cbo.getOrderID());
          BigDecimal price = cbo.getPrice();
          orders.add(new LimitOrder(Order.OrderType.ASK, cbo.getQuantity(), CurrencyPair.BTC_USD, id, cbo.getOrderEntered(), price));
        }
      }
      return new OpenOrders(orders);
    }
    else {
      throw new ExchangeException("Error calling getOpenOrders(): " + myOpenOrders.getError());
    }
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.campbx.dto.trade.MyOpenOrders

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.