com.xeiam.xchange.examples.btcchina.trade.BTCChinaGetOrderDemo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xchange-examples Show documentation
Show all versions of xchange-examples Show documentation
Provides a set of examples that demonstrate how to use XChange in client applications
The newest version!
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());
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy