Package com.xeiam.xchange.examples.btcchina.trade

Source Code of com.xeiam.xchange.examples.btcchina.trade.BTCChinaGetOrderDemo

package com.xeiam.xchange.examples.btcchina.trade;

import java.io.IOException;
import java.util.Date;

import com.xeiam.xchange.Exchange;
import com.xeiam.xchange.btcchina.dto.trade.BTCChinaOrder;
import com.xeiam.xchange.btcchina.dto.trade.BTCChinaOrderDetail;
import com.xeiam.xchange.btcchina.dto.trade.response.BTCChinaGetOrderResponse;
import com.xeiam.xchange.btcchina.service.polling.BTCChinaTradeServiceRaw;
import com.xeiam.xchange.examples.btcchina.BTCChinaExamplesUtils;

/**
* Demo for {@link BTCChinaTradeServiceRaw#getBTCChinaOrder}.
*/
public class BTCChinaGetOrderDemo {

  static Exchange btcchina = BTCChinaExamplesUtils.getExchange();
  static BTCChinaTradeServiceRaw tradeServiceRaw = (BTCChinaTradeServiceRaw) btcchina.getPollingTradeService();

  public static void main(String[] args) throws IOException {

    final int orderId = Integer.parseInt(args[0]);
    final String market = args.length > 1 ? args[1] : null;
    final Boolean withdetail = args.length > 2 ? Boolean.valueOf(args[2]) : null;

    BTCChinaGetOrderResponse response;
    if (market == null) {
      response = tradeServiceRaw.getBTCChinaOrder(orderId);
    }
    else if (withdetail == null) {
      response = tradeServiceRaw.getBTCChinaOrder(orderId, market);
    }
    else {
      response = tradeServiceRaw.getBTCChinaOrder(orderId, market, withdetail);
    }
    System.out.println(response);

    BTCChinaOrder order = response.getResult().getOrder();
    System.out.println("OrderID:\t" + order.getId());
    System.out.println("Side:\t" + order.getType());
    System.out.println("Price:\t" + order.getPrice());
    System.out.println("Currency: \t" + order.getCurrency());
    System.out.println("LeavesQty:\t" + order.getAmount());
    System.out.println("OrderQty:\t" + order.getAmountOriginal());
    System.out.println("CumQty:\t" + order.getAmountOriginal().subtract(order.getAmount()));
    System.out.println("Date:\t" + new Date(order.getDate() * 1000));
    System.out.println("Status:\t" + order.getStatus());
    if (order.getDetails() != null) {
      for (BTCChinaOrderDetail detail : order.getDetails()) {
        System.out.println("--");
        System.out.println("dateline:\t" + detail.getDateline());
        System.out.println("price:\t" + detail.getPrice());
        System.out.println("amount:\t" + detail.getAmount());
      }
    }
  }

}
TOP

Related Classes of com.xeiam.xchange.examples.btcchina.trade.BTCChinaGetOrderDemo

TOP
Copyright © 2018 www.massapi.com. 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.